MySql jar file constructor
Hello,
I am developing web application using JSP and MySql. I am using netBeans 4.1 as IDE.
To connect with database I have included jar file "mysql-connector-java-3.1.10-bin.jar" to Libraries folder of my project in netBeans. This jar file contains many classes, one which I want to use is com.mysql.jdbc.Blob.
In my jsp file I want to call Blob(byte[]) constructor. For that I am doing :
com.mysql.jdbc.Blob myBlob = new com.mysql.jdbc.Blob(dataBytes);
Where dataBytes is an initialized array of bytes.
When I compile my jsp file I get error "can not find symbol". It says it is not able to find constructor.
So where I am making mistake. To resolve this problem which actions should I take??
Jahnvi
Hello,
I am developing web application using JSP and MySql. I am using netBeans 4.1 as IDE.
To connect with database I have included jar file "mysql-connector-java-3.1.10-bin.jar" to Libraries folder of my project in netBeans. This jar file contains many classes, one which I want to use is com.mysql.jdbc.Blob.
In my jsp file I want to call Blob(byte[]) constructor. For that I am doing :
com.mysql.jdbc.Blob myBlob = new com.mysql.jdbc.Blob(dataBytes);
Where dataBytes is an initialized array of bytes.
When I compile my jsp file I get error "can not find symbol". It says it is not able to find constructor.
So where I am making mistake. To resolve this problem which actions should I take??
Jahnvi
Similar Messages
-
Don't know how to make my main class import a jar file
OK, the title doesn't make much sense but here are my create-jar.bat and manifest files:
create-jar.bat:
jar cvmf manifest.txt dassimul-admin.jar player/ admin/ com/ connector/ common/ *.class
manifest.txt:
Main-Class: admin.DASAdmin
the problem is that in connector/ folder there is the jdbc mysql connector driver (.jar file).
in Eclipse I can add this jar to the Java Build Path, so the program runs.
When I double-click the dassimul-admin.jar file, I get a Class Not Found Exception
C:\MYWORK\dassimul>java -jar dassimul-admin.jar
FATAL ERROR WHILE LOADING SQL DRIVER: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
I think that the problem lies in the fact that admin.DASAdmin can't see and import the jar file in connector/ folder... am I right?It looks like you are putting the mysql jar file inside the dassimul jar. That won't work unless you write custom code. You should use the Class-Path attribute of the manifest to define a relative path(s) to the other jar(s) that you need to use.
[http://java.sun.com/docs/books/tutorial/deployment/jar/index.html] -
How to include the mysql-connector in a simple .jar file
Well I started up with java again. Just messing around. This project I'm making now is just plain simple, I have a program thats going to read a table in a database from a server I have here at home. It works fine if I do like this: java javafil to run the file, it reads from the database fine.
But when I made a .jar file out of it using this command: jar cmf manifest.txt javafile.jar *.class
It won't connect to the database. Or it doesn't print out the rows in the table. So I thought I have to include the mysql-connector with the .jar.
manifest.txt
Main-Class: javafile
Now what is an easy way to do this?
This program is also going to be run from a computer that might not have the mysql-connector installed on the computer. Like a friend of mine wants to connect to the database and read it.
I've tried to google "mysql connector in a .jar file" but I get tons of informations about the mysql-connector.jar instead of what I'm looking for.
Thanks,
Torbj�rn Svae
Edited by: LordSvae on 19.jun.2008 14:52LordSvae wrote:
Yeah but the other computer might not have that connector file on their computer. So is there like I way I can use it when it is in the .jar file? Thats kinda what I wanted. You cannot include another JAR in a JAR file. You however can extract it and put the classes in your JAR. Verify the license agreement if it is allowed. Although this is considered as a bad practice (poor upgradebility and maintainability).
If you don't want to use the -cp parameter, then use the class-path entry of the manifest.mf of your JAR. You can also write a batch file with the whole JAR -cp command in a single line and run the batch file instead.
Pluss, even though I have the right classpath in the environment variables set, it doesn't work for me either. So I guess it doesn't load the connector when running the .jar file.The classpath environment variable has nothing to do with running JAR's. Forget about it and use the -cp or -classpath parameter. -
Hello all,
i am referring following link to create connector for connection between mysql and sqldeveloper,
while installing jar file for mysql J conncetor its telling unable to launch jar file.
This is the latest OS and they have java preferences from utility folder and gave java control panel instead in system prefernces which is picking the runtime latest java version from oracle site.
Please refer "http://reviews.cnet.com/8301-13727_7-57533880-263/java-preferences-missing-after -latest-os-x-java-update/" for the same.
Please suggest ASAP.
Thanks
AbhiNUsorry i missed link in above descriptin
http://mysql-dba-journey.blogspot.com/2009/05/installing-oracle-sql-developer-or acle.html -
im writing i database front end using eclipse
when i run the code it works fine and connects to the database
but when i make a jar file from the project it doesnt connect to mysqli think i set it to use the class files not the
source codehuh?
I meant what have you done with the driver jars
i dont get an exception it just doesnt connectOr probably you don't know how to see it on a console... -
Jar file and remote mysql connect
I have a jar file that i want anyone run it.The problem is that the code makes a connection to a database (mysql) to my computer.How anyone can connect to my databse in my computer from another pc without the user have to had the java \ mysql connect or hte mysql.Only the java.I try with a jnlp file and the jar file stored in my computer.I have a host name and i have open the port 3306 for mysql and allow remote connections to mysql.Can you help me;;
ok i connect to database like this:
try {
String userName = "username";
String password = "password";
String url = "jdbc:mysql://HOSTNAME/bankloans";
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection(url, userName, password);
} catch (Exception e) {
System.out.prinln(e);
}The JNPL file
<?xml version="1.0" encoding="Windows-1251"?>
<jnlp
spec="1.0+"
codebase="http://nasikas.ath.cx:8080/bankloans/"
href="BankLoans.jnlp">
<information>
<title>Bank Loans Programme</title>
<vendor>Softlets</vendor>
<description>Bank Loans Programme</description>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.6+"/>
<jar href="BankLoans.jar" main="true"/>
<jar href="mysql-connector-java-5.1.0-bin.jar"/>
</resources>
<application-desc main-class="Go"/>
</jnlp>What is wrong;; -
Jar file connection with mysql
Hello everyone i ve a problem if you people could solve please help...
When i compile my java code with mysql connection it works perfectly, but when i convert into jar file its not updating any values in the mysql database
Can anyone tell me a solution.subhavenkatesh wrote:
Can anyone tell me a solution.You have a bug. Find it. Fix it. -
Unable to extract connector/j jar file(mysql)
im have having a problem on extracting mysql's connector/j jar file on j2sdk1.4.0.
and may i know does sun allows windows xp users to install various kind of versions of j2sdk? for example, install j2sdk1.4.0 into c:\j2sdk1.4.0, and j2sdk1.4.2_05 into c:\j2sdk1.4.2_05?
what to do using j2sdk1.4.0 for connector/j?
i would like to know manual steps instead if automatic step provided by netbean.
i wish this problem could be solved as sonn as possibleim have having a problem on extracting mysql's
connector/j jar file on j2sdk1.4.0.I'm not sure what this means. The MySQL connector JAR isn't part of any JDK. You've got to download it and put it in your CLASSPATH.
>
and may i know does sun allows windows xp users to
install various kind of versions of j2sdk? for
example, install j2sdk1.4.0 into c:\j2sdk1.4.0, and
j2sdk1.4.2_05 into c:\j2sdk1.4.2_05?
what to do using j2sdk1.4.0 for connector/j?
i would like to know manual steps instead if
automatic step provided by netbean.
i wish this problem could be solved as sonn as
possible -
Help needed: getting jar files to work.
Right, to start off, i have been doing php and mysql for a long time and i thought it's time to start using java.
So now im trying to create an application. I use eclipse. All works well if i run the program from eclipse. But i want to create and executable or a jar file first. I used JSmooth but with that i get an error "Could not find the main class".
While exporting the project as a jar i specified the main class in manifest specification.
So these are my classes:
the Main.class
public class Main{
public static void main(String[] args) {
PageFrame page = new PageFrame();
page.show();
}and the PageFrame.class
import java.net.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
class PageFrame extends JFrame implements ActionListener,MouseListener{
String[] skillnames = {"attack","hitpoints","mining","strength","agility","smithing","defence","herblore","fishing","ranged","thieving","cooking",
"prayer","crafting","firemaking","magic","fletching","woodcutting","runecraft","slayer","farming","construction","hunter","summoning"};
JTextField username = new JTextField("",12);
JTextArea box = new JTextArea(10,12);
JButton search = new JButton("Search");
int[] differences = {0,83,174,276,388,512,650,801,969,1154,1358,1584,1833,2107,2411,2746,3115,3523,3973,4470,5018,5624,6291,7028,7824,
8740,9730,10824,12031,13363,14833,16456,18247,20224,22406,24815,27473,30408,33648,37224,41171,45529,50339,55649,61512,67983,
75127,83014,91721,101333,111945,122660,136594,150872,166636,184040,203254,224466,247886,273742,302288,333804,368599,407015,
449428,496254,547953,605032,668051,737627,814445,899257,992895,1096278,1210421,1336443,1475581,1629200,1798808,1986068,2192818,
2421087,2673114,2951373,3258594,3597792,3972294,4385776,4842295,5346332,5902831,6517253,7195629,7944614,8771558,9684577,10692629,
11805606,13034431,14567891};
URL page;
static String name;
JLabel[] skills = new JLabel[24];
JLabel skillicons = new JLabel();
public PageFrame(){
super("Stats Lookup");
setSize(800,600);
setResizable(false);
try{
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
SwingUtilities.updateComponentTreeUI(this);
}catch (Exception e){
System.err.println("Yo" + e);
//teen labelid;
for (int i = 0; i < skills.length;i++){
ImageIcon icon = new ImageIcon(PageFrame.class.getResource("images/skillimages/" + skillnames[i] + ".gif"));
skills[i] = new JLabel("00",icon,JLabel.CENTER);
JPanel pane = new JPanel();
GridBagLayout maingrid = new GridBagLayout();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GridBagConstraints constraints = new GridBagConstraints();
JPanel skillPane = new JPanel();
GridBagLayout levelslyo = new GridBagLayout();
GridBagConstraints sConstraints = new GridBagConstraints();
sConstraints.ipadx = 15;
sConstraints.ipady = 10;
skillPane.setLayout(levelslyo);
int k = 0;
int m = 1;
buildconstraints(sConstraints,12,4,1,1,2,2);
skillPane.add(skillicons);
for (int i = 0; i < skills.length;i++){
buildconstraints(sConstraints,m,k,1,1,2,2);
levelslyo.setConstraints(skills, sConstraints);
//skills[i].setText(" 0 ");
skillPane.add(skills[i]);
skills[i].addMouseListener(this);
m+=2;
if (m == 7){
m = 1;
k +=1;
/*m = 0;
k = 0;
for (int i = 0; i < skills.length;i++){
System.out.println("Paremale: " + m + " Alla: " + k);
buildconstraints(sConstraints,m,k,1,1,2,2);
levelslyo.setConstraints(skillicons, sConstraints);
skillicons = new JLabel(icon);
skillPane.add(skillicons);
m+=2;
if (m == 6){
m = 0;
k +=1;
buildconstraints(constraints,0,0,1,1,100,100);
maingrid.setConstraints(username, constraints);
buildconstraints(constraints,1,0,1,1,100,100);
maingrid.setConstraints(search, constraints);
buildconstraints(constraints,0,1,1,1,100,100);
maingrid.setConstraints(skillPane, constraints);
pane.setLayout(maingrid);
constraints.fill = GridBagConstraints.BOTH;
search.addActionListener(this);
box.setEditable(false);
buildconstraints(constraints,1,1,2,1,120,100);
maingrid.setConstraints(box, constraints);
pane.add(username);
pane.add(search);
pane.add(box);
pane.add(skillPane);
setContentPane(pane);
//getContentPane().add(scroll);
pack();
setVisible(true);
WindowListener l = new WindowAdapter(){
public void windowClosing(WindowEvent evt){
System.exit(0);
addWindowListener(l);
void buildconstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx,int wy){
gbc.gridx = gx;
gbc.gridy = gy;
gbc.gridwidth = gw;
gbc.gridheight = gh;
gbc.weightx = wx;
gbc.weighty = wy;
/*Vector ranks = new Vector();
Vector levels = new Vector();
Vector exp = new Vector();*/
class Stats{
int[] levels = new int[34];
int[] experience = new int[34];
int[] ranks = new int[34];
Stats stats = new Stats();
public void getStats(URL url){
URLConnection conn = null;
InputStreamReader in;
BufferedReader data;
String line;
StringBuffer buf = new StringBuffer();
try{
conn = this.page.openConnection();
conn.connect();
//box.setText("Connection opened");
in = new InputStreamReader(conn.getInputStream());
data = new BufferedReader(in);
//box.setText("Reading data...");
int ts=0;
while ((line = data.readLine()) != null){
buf.append(line + "\n");
StringTokenizer tokenize;
tokenize = new StringTokenizer(line.toString(),",");
int[][] paarid = {{1,0},{2,3},{3,6},{4,1},{5,9},{6,12},{7,15},{8,11},{9,17},{10,16},{11,8},{12,14},{13,13},
{14,5},{15,2},{16,7},{17,4},{17,10},{19,19},{20,20},{21,18},{22,22},{23,21},{24,23}};
if (ts < 25 && ts > 0){
int slot = paarid[ts-1][1];
stats.ranks[slot] = Integer.parseInt(tokenize.nextToken());
int yo = Integer.parseInt(tokenize.nextToken());
stats.levels[slot] =yo;
stats.experience[slot] = Integer.parseInt(tokenize.nextToken());
ts++;
for (int i = 0; i < skills.length;i++){
String text = ""+stats.levels[i];//testings[i];//
skills[i].setText(text);
}catch(IOException e){
box.setText("Insert a username \nfirst!");
public String getNextXp(int level, int currxp){
String nextXp;
if (level > 98){
nextXp = "N/A";
}else{
nextXp = ""+(differences[level] - currxp);
return nextXp;
public void actionPerformed(ActionEvent evt){
String newuser = username.getText().toString();
name = newuser;
String address = "http://hiscore.runescape.com/index_lite.ws?player="+name;
try{
page = new URL(address);
getStats(page);
}catch(MalformedURLException e){
box.setText("Insert a username");
repaint();
public void mouseEntered(MouseEvent e) {
//if (experience[].isEmpty()){
Object s = e.getSource();
for (int i = 0; i < skills.length;i++){
if (s == skills[i]){
box.setText("Rank: " + stats.ranks[i] + "\nExperience: " + stats.experience[i] + "\nExp until next: " + getNextXp(stats.levels[i],stats.experience[i]));
public void mouseExited(MouseEvent e) {
box.setText("");
public void mouseClicked(MouseEvent e) {
public void mousePressed(MouseEvent e) {
public void mouseReleased(MouseEvent e) {
This is just a little project i thought i'd make for learning.
But can anyone help me make a working jar or an exe file?
The Jar i created does nothing, no error or anything.
Thanks for Help.How should i run the jar file then? I am double clicking it yes.
EDIT: i ran the program through command line and i got an error:
Exception in thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at PageFrame.<init>(PageFrame.java:41)
at Main.main(Main.java:4)OK - so it looks like you've found a command line!
You read these stack traces from the top down. Often the most interesting line is the first line that refers to your code. In this case line 41 of PageFrame.java which, I guess is this:
ImageIcon icon = new ImageIcon(PageFrame.class.getResource(
"images/skillimages/" + skillnames[i] + ".gif"));The ImageIcon constructor is grumbling about being told to construct an icon from a null resource. getResource() will return null if it cannot find the resource that you specify.
The first thing to do is check that the .gif image is where it should be. You have specified it as "images/skillimages/etc" so use the command line to view the contents of the .jar file (or maybe Eclipse will let you do this). Next to PageFrame.class there should be a folder "images" and within it a folder "skillimages" and within that the image file. If not then your jar export has been seen up wrongly and is not including the required resource files.
(The "View" command is explained here: [http://java.sun.com/docs/books/tutorial/deployment/jar/view.html].)
Next check the case of the file names. On Windows getResource() will not worry about the cAsE of filenames so the resources will be located fine when running the program unjarred (including within Eclipse). But it does worry about the case of jar entry names. Bottom line: keep the file names all lower case because you use them that way in the code.
Finally, in case it is a particular image resource that's causing the problem you could add some code to print out its name just before you try and create the icon.
for (int i = 0; i < skills.length;i++){
System.out.println(
"About to make icon from " + "images/skillimages/" + skillnames[i] + ".gif");
ImageIcon icon = new ImageIcon(PageFrame.class.getResource(
"images/skillimages/" + skillnames[i] + ".gif"));
skills[i] = new JLabel("00",icon,JLabel.CENTER);
} -
Unable to load database driver from my applet's jar file
I'm trying to set up an applet that will talk to a MySQL database. I have no problem connecting to the database as I'm developing the code ("un-jarred"), but when I create a jar file of my code to test through a web browser, I cannot connect to the database due to the usual ClassNotFoundException. I have included mysql-connector-java-3.1.12-bin.jar (the current driver) in the jar, but I don't know if I'm supposed to supply some info through an attribute to the applet tag to let it know that the jar contains the driver it needs or if I have to call the driver differently in my code.
Any help is appreciated, thanks.The simplest approach is always the best. :)Abso-lutely.
Awesome, that worked perfectly. I Included the extra
jar file in the applet tag and now my applet makes
some sweet lovin' to the database.And you have succeeded where thousands have failed. Congratulations. -
Crystal Report not works in JAR File
I'm using Eclipse All in one, which includes Crystal Reports.. I Connected my Java program with Crystal Reports and its working properly. Now my problem is that the Report is not working in JAR files.. It throws some exception as
"com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: com.businessobjects
com.businessobjects.reports.sdk.JRCCommunicationAdapter---- Error code:-2147215357 Error code name:internal"
Whats the Error.. I don't know. I think that i may missed some CLASSPATH Files. The included CLASSPATH Files are:
ReportViewer.jar
jrcerom.jar
Concurrent.jar
CrystalCharting.jar
CrystalCommon.jar
CrystalContentModels.jar
CrystalExporters.jar
CrystalExportingBase.jar
CrystalFormulas.jar
CrystalQueryEngine.jar
CrystalReportEngine.jar
CrystalReportingCommon.jar
icu4j.jar
keycodeDecoder.jar
log4j.jar
MetafileRenderer.jar
rasapp.jar
rascore.jar
rpoifs.jar
Serialization.jar
URIUtil.jar
xercesImpl.jar
xml-apis.jar
and the mysql-connector jar file
Anybody help me please...Unable to load database connector
'com.crystaldecisions.reports.queryengine..driverImpl.
DriverLoader
now you have any idea.. pleaseIs that a typo where you have two periods below?
queryengine..driverImplOther than that I don't think anybody here can help you with that. If your classpath includes all necessary JAR files and you are able to access all your resources from within your application JAR file, then I imagine there is a problem with the third-party crystal decisions JAR file or how you are attempting to use it.
My advice to you is to try and contact support with the vendor or provider of this API or possibly try posting on a support forum on their website to see if somebody can help you there. -
Access of MySQlL Driver class by eclipse but not from Outside Jar file
Dear All,
I have done a standalone application having access with MySQl database.
I could access it when i execute it from eclipse. But when i export it into Jar file and running I get MySQL Driver class not found exception.
Give me a better solution for this issue.CLASSPATH, CLASSPATH, CLASSPATH.
You have defined the Eclipses Project Library Path to include the MySQL jar, but ar not including it on the classpath when executing the jar.
Either modify the MANIFEST.mf file in the jar to include a reference to the MySQL driver jarfile or call java in the following manner
java -cp /full/path/to/MySQL/Driver/jarfile.jar -jar yourJarFile.jarObviously, if this is on Windows and you are executing through a double click, the first option is the best option. -
How to create package and import from jar file?
Hi all,
I am writing a software and I am not sure how to create a package for the classes.
Say I have two classes in the same directory as follows:
testA.java
==========
package AB;
public class testA
public static void main(String[] args){
testB myB = new testB();
System.out.println("A test");
testB.java
===========
package AB;
public class testB
public testB(){
System.out.println("B constructor");
both file compile without the package heading;
both file compile using: javac -classpath .\ *.java
Question 1:
I cannot run testA by: java -classpath .\ testA
I think it is a syntax error. What is the correct one?
If I run testA by: java testA
The only output I get is: A test
But I am expecting: B constructor /n A test
What went wrong?
Question 2:
I need to use APIs of another software. I have downloaded a .jar file (xxx.jar) with all the classes in it. And I have put "import xxx.*;" in my source file. But the compiler complains about the importing. What is the right way to copmile it?
I have read a couple of tutorials but they don't answer my question.
(I am using windows2000 and don't have the classpath variable.)
Hope some one can help.
Thanks a lotTry moving testA out of the package and importing 'AB.*;'
If you have:
./testA.class
./AB/testb.class
Then to execute testA from ./ type: java -cp . testA -
Problem in Creating a jar file using java.util.jar and deploying in jboss 4
Dear Techies,
I am facing this peculiar problem. I am creating a jar file programmatically using java.util.jar api. The jar file is created but Jboss AS is unable to deploy this jar file. I have also tested that my created jar file contains the same files. When I create a jar file from the command using jar -cvf command, Jboss is able to deploy. I am sending the code , please review it and let me know the problem. I badly require your help. I am unable to proceeed in this regard. Please help me.
package com.rrs.corona.solutionsacceleratorstudio.solutionadapter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import com.rrs.corona.solutionsacceleratorstudio.SASConstants;
* @author Piku Mishra
public class JarCreation
* File object
File file;
* JarOutputStream object to create a jar file
JarOutputStream jarOutput ;
* File of the generated jar file
String jarFileName = "rrs.jar";
*To create a Manifest.mf file
Manifest manifest = null;
//Attributes atr = null;
* Default Constructor to specify the path and
* name of the jar file
* @param destnPath of type String denoting the path of the generated jar file
public JarCreation(String destnPath)
{//This constructor initializes the destination path and file name of the jar file
try
manifest = new Manifest();
jarOutput = new JarOutputStream(new FileOutputStream(destnPath+"/"+jarFileName),manifest);
catch(Exception e)
e.printStackTrace();
public JarCreation()
* This method is used to obtain the list of files present in a
* directory
* @param path of type String specifying the path of directory containing the files
* @return the list of files from a particular directory
public File[] getFiles(String path)
{//This method is used to obtain the list of files in a directory
try
file = new File(path);
catch(Exception e)
e.printStackTrace();
return file.listFiles();
* This method is used to create a jar file from a directory
* @param path of type String specifying the directory to make jar
public void createJar(String path)
{//This method is used to create a jar file from
// a directory. If the directory contains several nested directory
//it will work.
try
byte[] buff = new byte[2048];
File[] fileList = getFiles(path);
for(int i=0;i<fileList.length;i++)
if(fileList.isDirectory())
createJar(fileList[i].getAbsolutePath());//Recusive method to get the files
else
FileInputStream fin = new FileInputStream(fileList[i]);
String temp = fileList[i].getAbsolutePath();
String subTemp = temp.substring(temp.indexOf("bin")+4,temp.length());
// System.out.println( subTemp+":"+fin.getChannel().size());
jarOutput.putNextEntry(new JarEntry(subTemp));
int len ;
while((len=fin.read(buff))>0)
jarOutput.write(buff,0,len);
fin.close();
catch( Exception e )
e.printStackTrace();
* Method used to close the object for JarOutputStream
public void close()
{//This method is used to close the
//JarOutputStream
try
jarOutput.flush();
jarOutput.close();
catch(Exception e)
e.printStackTrace();
public static void main( String[] args )
JarCreation jarCreate = new JarCreation("destnation path where jar file will be created /");
jarCreate.createJar("put your source directory");
jarCreate.close();Hi,
I have gone through your code and the problem is that when you create jar it takes a complete path address (which is called using getAbsolutePath ) (when you extract you see the path; C:\..\...\..\ )
You need to truncate this complete path and take only the path address where your files are stored and the problem must be solved. -
Problem using a jar file : java.lang.ClassNotFoundException: ApiConn
Hi everyone.
i am running a form that use a bean_area to call a jar.
but i am getting this error, thanks in advnce for any tip.
Java Plug-in 1.6.0_33
Using JRE version 1.6.0_33-b05 Java HotSpot(TM) Client VM
User home directory = C:\Users\user1
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
java.lang.ClassNotFoundException: ApiConn
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at oracle.forms.handler.UICommon.instantiate(Unknown Source)
at oracle.forms.handler.UICommon.onCreate(Unknown Source)
at oracle.forms.handler.JavaContainer.onCreate(Unknown Source)
at oracle.forms.engine.Runform.onCreateHandler(Unknown Source)
at oracle.forms.engine.Runform.processMessage(Unknown Source)
at oracle.forms.engine.Runform.processSet(Unknown Source)
at oracle.forms.engine.Runform.onMessageReal(Unknown Source)
at oracle.forms.engine.Runform.onMessage(Unknown Source)
at oracle.forms.engine.Runform.processEventEnd(Unknown Source)
at oracle.ewt.lwAWT.LWComponent.redispatchEvent(Unknown Source)
at oracle.ewt.lwAWT.LWComponent.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Dumping class loader cache...
Live entry: key=http://192.168.10.100:7778/forms/java/,frmall.jar,siberia_jpg.jar,ApiConn.jar,Hasher.jar,ReadCommand.jar,WriteCommand.jar,libAPI.jar, refCount=1, threadGroup=sun.plugin2.applet.Applet2ThreadGroup[name=http://192.168.10.100:7778/forms/java/-threadGroup,maxpri=4]
Done.
in my form i have created a bean_area and used as implementation class :ApiConn
in my formsweb.cfg i used this configuration: archive=frmall.jar,siberia_jpg.jar,ApiConn.jar,Hasher.jar,ReadCommand.jar,WriteCommand.jar,libAPI.jar
in my forms/java i have placed my jar files listed in the frmall.jar
i guess i am missing something but i dont know what it is.
here is my ApiConn.java from wich i generate my jar file:
package libAPI;
* This contains connection. Everything should be here,
* should operate with this class only
import java.io.*;
import java.net.*;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.logging.Level;
import java.util.logging.Logger;
* @author janisk
public class ApiConn extends Thread {
private Socket sock = null;
private DataOutputStream out = null;
private DataInputStream in = null;
private String ipAddress;
private int ipPort;
private boolean connected = false;
private String message = "Not connected";
private ReadCommand readCommand = null;
private WriteCommand writeCommand = null;
private Thread listener = null;
LinkedBlockingQueue queue = new LinkedBlockingQueue(40);
* Constructor of the connection class
* @param ipAddress - IP address of the router you want to conenct to
* @param ipPort - port used for connection, ROS default is 8728
public ApiConn(String ipAddress, int ipPort) {
this.ipAddress = ipAddress;
this.ipPort = ipPort;
this.setName("settings");
* State of connection
* @return - if connection is established to router it returns true.
public boolean isConnected() {
return connected;
public void disconnect() throws IOException{
listener.interrupt();
sock.close();
private void listen() {
if (this.isConnected()) {
if (readCommand == null) {
readCommand = new ReadCommand(in, queue);
listener = new Thread(readCommand);
listener.setDaemon(true);
listener.setName("listener");
listener.start();
* to get IP address of the connection. Reads data from socket created.
* @return InetAddress
public InetAddress getIpAddress() {
return sock == null ? null : sock.getInetAddress();
* returns ip address that socket is asociated with.
* @return InetAddress
public InetAddress getLocalIpAddress() {
return sock == null ? null : sock.getLocalAddress();
* Socket remote port number
* @return
public int getPort() {
return sock == null ? null : sock.getPort();
* return local prot used by socket
* @return
public int getLocalPort() {
return sock == null ? null : sock.getLocalPort();
* Returns status message set up bu class.
* @return
public String getMessage() {
return message;
* sets and exectues command (sends it to RouterOS host connected)
* @param s - command will be sent to RouterOS for example "/ip/address/print\n=follow="
* @return
public String sendCommand(String s) {
return writeCommand.setCommand(s).runCommand();
* exeecutes already set command.
* @return returns status of the command sent
public String runCommand() {
return writeCommand.runCommand();
* Tries to fech data that is repllied to commands sent. It will wait till it can return something.
* @return returns data sent by RouterOS
* @throws java.lang.InterruptedException
public String getData() throws InterruptedException {
String s = (String) queue.take();
return s;
* returns command that is set at this moment. And will be exectued if runCommand is exectued.
* @return
public String getCommand() {
return writeCommand.getCommand();
* set up method that will log you in
* @param name - username of the user on the router
* @param password - password for the user
* @return
public String login(String name, char[] password) {
this.sendCommand("/login");
String s = "a";
try {
s = this.getData();
} catch (InterruptedException ex) {
Logger.getLogger(ApiConn.class.getName()).log(Level.SEVERE, null, ex);
return "failed read #1";
if (!s.contains("!trap") && s.length() > 4) {
String[] tmp = s.trim().split("\n");
if (tmp.length > 1) {
tmp = tmp[1].split("=ret=");
s = "";
String transition = tmp[tmp.length - 1];
String chal = "";
chal = Hasher.hexStrToStr("00") + new String(password) + Hasher.hexStrToStr(transition);
chal = Hasher.hashMD5(chal);
String m = "/login\n=name=" + name + "\n=response=00" + chal;
s = this.sendCommand(m);
try {
s = this.getData();
} catch (InterruptedException ex) {
Logger.getLogger(ApiConn.class.getName()).log(Level.SEVERE, null, ex);
return "failed read #2";
if (s.contains("!done")) {
if (!s.contains("!trap")) {
return "Login successful";
return "Login failed";
@Override
public void run() {
try {
InetAddress ia = InetAddress.getByName(ipAddress);
if (ia.isReachable(1000)) {
sock = new Socket(ipAddress, ipPort);
in = new DataInputStream(sock.getInputStream());
out = new DataOutputStream(sock.getOutputStream());
connected = true;
readCommand = new ReadCommand(in, queue);
writeCommand = new WriteCommand(out);
this.listen();
message = "Connected";
} else {
message = "Not reachable";
} catch (UnknownHostException ex) {
connected = false;
message = ex.getMessage();
ex.printStackTrace();
} catch (IOException ex) {
connected = false;
message = ex.getMessage();
ex.printStackTrace();
}I need your help again, i think this is a minor thing.
i have compiled the class file that i needed and i signed it too. but now it is giving me a new error and need your tip.
here is the java console loyout and my java file ((i think here is the problem in java file, something must be missing)).
thanks in advance for any help.
Java Plug-in 10.17.2.02
Using JRE version 1.7.0_17-b02 Java HotSpot(TM) Client VM
User home directory = C:\Users\Administrator
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
network: Connecting http://192.168.10.100:7778/forms/lservlet;jsessionid=c0a80a6430d6e191eded93774f2f8d1bed73056e66ef.e3mObhiMbxeKe34PahiKbx4Nbh90n6jAmljGr5XDqQLvpAe with proxy=DIRECT
security: Validate the certificate chain using CertPath API
security: The certificate hasnt been expired, no need to check timestamping info
security: Cannot find jurisdiction list file
security: The CRL support is disabled
security: The OCSP support is disabled
security: This OCSP End Entity validation is disabled
security: Checking if certificate is in Deployment denied certificate store
security: Checking if certificate is in Deployment permanent certificate store
basic: updateValidationResultsForApplet update
cache: Mark prevalidated: http://192.168.10.100:7778/forms/java/ApiConn.jar true tm=1363335797289 cert=1371107987000
basic: Plugin2ClassLoader.getPermissions CeilingPolicy allPerms
java.lang.InstantiationException: oracle.forms.siberia.ApiConn
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at oracle.forms.handler.UICommon.instantiate(Unknown Source)
at oracle.forms.handler.UICommon.onCreate(Unknown Source)
at oracle.forms.handler.JavaContainer.onCreate(Unknown Source)
at oracle.forms.engine.Runform.onCreateHandler(Unknown Source)
at oracle.forms.engine.Runform.processMessage(Unknown Source)
at oracle.forms.engine.Runform.processSet(Unknown Source)
at oracle.forms.engine.Runform.onMessageReal(Unknown Source)
at oracle.forms.engine.Runform.onMessage(Unknown Source)
at oracle.forms.engine.Runform.processEventEnd(Unknown Source)
at oracle.ewt.lwAWT.LWComponent.redispatchEvent(Unknown Source)
at oracle.ewt.lwAWT.LWComponent.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
network: Connecting http://192.168.10.100:7778/forms/lservlet;jsessionid=c0a80a6430d6e191eded93774f2f8d1bed73056e66ef.e3mObhiMbxeKe34PahiKbx4Nbh90n6jAmljGr5XDqQLvpAe with proxy=DIRECT
Exception in thread "Forms-DialogThread2" java.lang.NullPointerException
at oracle.forms.handler.JavaContainer.onDestroy(Unknown Source)
at oracle.forms.engine.Runform.destroyHandlers(Unknown Source)
at oracle.forms.handler.DialogThread.doAlert(Unknown Source)
at oracle.forms.handler.DialogThread.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Dumping class loader cache...
Live entry: key=http://192.168.10.100:7778/forms/java/,frmall.jar,siberia_jpg.jar,ApiConn.jar,ConcealTextField.jar, refCount=1, threadGroup=sun.plugin2.applet.Applet2ThreadGroup[name=http://192.168.10.100:7778/forms/java/-threadGroup,maxpri=4]
Done.
here is my java file
* To change this template, choose Tools | Templates
* and open the template in the editor.
package oracle.forms.siberia;
* This contains connection. Everything should be here,
* should operate with this class only
import java.io.*;
import java.net.*;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.logging.Level;
import java.util.logging.Logger;
import oracle.forms.*;
* @author janisk
public class ApiConn extends Thread {
private Socket sock = null;
private DataOutputStream out = null;
private DataInputStream in = null;
private String ipAddress;
private int ipPort;
private boolean connected = false;
private String message = "Not connected";
private ReadCommand readCommand = null;
private WriteCommand writeCommand = null;
private Thread listener = null;
LinkedBlockingQueue queue = new LinkedBlockingQueue(40);
* Constructor of the connection class
* @param ipAddress - IP address of the router you want to conenct to
* @param ipPort - port used for connection, ROS default is 8728
public ApiConn(String ipAddress, int ipPort) {
this.ipAddress = ipAddress;
this.ipPort = ipPort;
this.setName("settings");
* State of connection
* @return - if connection is established to router it returns true.
public boolean isConnected() {
return connected;
public void disconnect() throws IOException{
listener.interrupt();
sock.close();
private void listen() {
if (this.isConnected()) {
if (readCommand == null) {
readCommand = new ReadCommand(in, queue);
listener = new Thread(readCommand);
listener.setDaemon(true);
listener.setName("listener");
listener.start();
* to get IP address of the connection. Reads data from socket created.
* @return InetAddress
public InetAddress getIpAddress() {
return sock == null ? null : sock.getInetAddress();
* returns ip address that socket is asociated with.
* @return InetAddress
public InetAddress getLocalIpAddress() {
return sock == null ? null : sock.getLocalAddress();
* Socket remote port number
* @return
public int getPort() {
return sock == null ? null : sock.getPort();
* return local prot used by socket
* @return
public int getLocalPort() {
return sock == null ? null : sock.getLocalPort();
* Returns status message set up bu class.
* @return
public String getMessage() {
return message;
* sets and exectues command (sends it to RouterOS host connected)
* @param s - command will be sent to RouterOS for example "/ip/address/print\n=follow="
* @return
public String sendCommand(String s) {
return writeCommand.setCommand(s).runCommand();
* exeecutes already set command.
* @return returns status of the command sent
public String runCommand() {
return writeCommand.runCommand();
* Tries to fech data that is repllied to commands sent. It will wait till it can return something.
* @return returns data sent by RouterOS
* @throws java.lang.InterruptedException
public String getData() throws InterruptedException {
String s = (String) queue.take();
return s;
* returns command that is set at this moment. And will be exectued if runCommand is exectued.
* @return
public String getCommand() {
return writeCommand.getCommand();
* set up method that will log you in
* @param name - username of the user on the router
* @param password - password for the user
* @return
public String login(String name, char[] password) {
this.sendCommand("/login");
String s = "a";
try {
s = this.getData();
} catch (InterruptedException ex) {
Logger.getLogger(ApiConn.class.getName()).log(Level.SEVERE, null, ex);
return "failed read #1";
if (!s.contains("!trap") && s.length() > 4) {
String[] tmp = s.trim().split("\n");
if (tmp.length > 1) {
tmp = tmp[1].split("=ret=");
s = "";
String transition = tmp[tmp.length - 1];
String chal = "";
chal = Hasher.hexStrToStr("00") + new String(password) + Hasher.hexStrToStr(transition);
chal = Hasher.hashMD5(chal);
String m = "/login\n=name=" + name + "\n=response=00" + chal;
s = this.sendCommand(m);
try {
s = this.getData();
} catch (InterruptedException ex) {
Logger.getLogger(ApiConn.class.getName()).log(Level.SEVERE, null, ex);
return "failed read #2";
if (s.contains("!done")) {
if (!s.contains("!trap")) {
return "Login successful";
return "Login failed";
@Override
public void run() {
try {
InetAddress ia = InetAddress.getByName(ipAddress);
if (ia.isReachable(1000)) {
sock = new Socket(ipAddress, ipPort);
in = new DataInputStream(sock.getInputStream());
out = new DataOutputStream(sock.getOutputStream());
connected = true;
readCommand = new ReadCommand(in, queue);
writeCommand = new WriteCommand(out);
this.listen();
message = "Connected";
} else {
message = "Not reachable";
} catch (UnknownHostException ex) {
connected = false;
message = ex.getMessage();
ex.printStackTrace();
} catch (IOException ex) {
connected = false;
message = ex.getMessage();
ex.printStackTrace();
}
Maybe you are looking for
-
Step By Step Creation Of A new Business Object
hi, Please Give Me Details Of A Business Object,like step by step creation of a new business object and it's utilization.
-
Hi, I am having this problem: I made a CustomItem, a TextField, now I overloaded the traverse method, so if the keycode is Canvas.UP or Canvas.DOWN then return false else return true. The problem is that when I press the left or rigth button it also
-
There is a smartform developed for my client instead of SAPSCRIPT for program RIPCT00(i.e TCODE - IW32). In smartform client wants to have 2 fields. 1 - How many Maintenance order created of the eqiupment 2 - Last Maintenance order of selected equip
-
What do I do if all of my photos turned into skype icons?
So I went on to iPhoto and all of the sudden all of my old pictures of family,friends are now emotions like this: and skype icons. I really need my old pictures back. How do I do this? Any help is appreciated because I need these pictures back asap
-
How to customize homepage role-based?
Hi, I want to customize the homepage in crm2007 by role. I customized the menu entries but cant find the right place for the homepage. I checked the component workbench but couldnt find what I was looking for. Can anybody help? Thanks a lot.