Java apps runs fine but gives error from jar file-NoClassDefFoundError
Hello,
I seem to be having a problem creating a jar file that I can use to access a mysql data base. I am using Linux Fedora Core 3, jave jdk1.5.0_04, mysql DB and the j/connector from the mysql site (mysql-connector-java-3.1.12). I have the jar file for the connector in jdk1.5.0_04/jre/lib/ext/mysql-connector-java-3.1.12-bin.jar ( am not sure that is the correct place but I have tried several different locations to no avail). I am using the eclipse IDE to create the programs and everything runs great while in the ide. Eclipse uses the directory workspace for its work area and I have created a project othertest. Here is the directory listing for that project:
bin (this is the directory where the class files are kept)
ShowWxData.jar
ShowWxData.mf
src (this is the directory where the java files are kept)
the listing for the bin directory:
>ls -1 bin
ShowWxData.class
WxStationData.class
when I cd into the bin directory and run the java program all is good:
[lbyrd@localhost bin]$ java ShowWxData
Current Conditions as of 2006-04-21 12:51:35.0
Partially Cloudy
Temperature ouside 69.3 deg F with humidity at 59%
Winds from 201 deg. at 11mph
Last wind gust from 202deg. at 13mph
Forecast: Partly cloudy with little temperature change..
+ + + + + + + + + + + + + + + + + + +
However when I move up one directory and try to use the jar file, this is what I get:
[lbyrd@localhost othertest]$ java -jar ShowWxData.jar
Exception in thread "main" java.lang.NoClassDefFoundError: ShowWxData
Here is the contents of the jar file:
>jar -tf ShowWxData.jar
META-INF/
META-INF/MANIFEST.MF
bin/ShowWxData.class
bin/WxStationData.class
/usr/java/jdk1.5.0_04/jre/lib/ext/mysql-connector-java-3.1.12-bin.jar
here is the manifest file:
cat ShowWxData.mf
Manifest-Version: 1.0
Class-Path: . /usr/java/jdk1.5.0_04/jre/lib/ext/mysql-connector-java-3.1.12-bin.jar
Main-Class: ShowWxData
What I am doing wrong so the jar file does not work. Any help/hints are greatly appreicated.
Lyman
|