problem to solve classpath

Michel Maria-Sube <[email protected]> Fri, 9 Nov 2007 12:18:36 -0800 (PST)
Newsgroups gmane.comp.db.mysql.java
Message-ID <[email protected]>
Hello,

I'm working under UNIX Suse 10.2 and using version
3.1.14 of jdbc; my application is apparently unable to
find path of classes defined in the jdbc archive. At
the beginning, application try to load driver class as
follows:

import  javax.swing.*;
import  java.lang.*;
import  java.net.*;
import  java.awt.*;
import  java.awt.event.*;
import  javax.swing.border.*;
import  java.sql.Connection;
import  java.sql.DriverManager;
import  java.sql.SQLException;
import  java.io.*;
import  java.util.Vector;

...

public class <the_main_class> {
....

public void connectDB( String DBName, String user,
String passwd )
{
...                
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (ClassNotFoundException cnfe) {
System.out.println("\nClassNotFoundException
occured");
System.out.println("connection with the DB is not
possible");
System.exit(ERROR);
}
.....
} //end of method

....
public static void main( String args[] ) {
........
}
} //end of main class

at execution, piece of code defined in the method
corpse:

Class.forName("com.mysql.jdbc.Driver").newInstance();

create exception: ClassNotFoundException

Before compiling, I set CLASSPATH variable as:

export
CLASSPATH='/usr/share/jdbc/mysql-connector-java-3.1.14-bin.jar'

then I compile with standard command:

javac *.java 

and create jar executable with command:

jar cvfm runme.jar ./META-INF/MANIFEST.MF *.class

The sole way i found to solve path of Driver class is
to put directly in the jar executable content of class
files, i.e to extract the com directory (under current
location) from jdbc archive and then update runme.jar
by doing:

jar uvf runme.jar com

but this solution is unacceptable; I precise too that
when I  was working previously under another linux
distro (mandrake10) I didn't encounter this problem,
classes where found just by specifying classpath
value; this seems rather uncreadible even for me but
maybe have i forgot or uncorrectly set
something...well suggestions are welcome...Thank you
in advance

Michel

-- 
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe:    http://lists.mysql.com/[email protected]