i have a simple Demo.java file in D:\jarConcepts directory:
import javax.swing.* ;
class Demo{
public static void main(String args[]){
JFrame frame = new JFrame("") ;
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE) ;
Class c = null ;
try{
c = Class.forName("com.mysql.jdbc.Driver") ;
//com.mysql.jdbc.Driver class is in a jar file
//whose class path is set in the environment variable(explicitly done by me)
//when i am executing Demo.class using java command, it displays frame with OK title
//but if i execute this by creating a jar, it enables to load the
//com.mysql.jdbc.Driver class,
//thus displaying frame with Sorry title
frame.setTitle("OK") ;
}
catch(ClassNotFoundException cnfe){
frame.setTitle("Sorry") ;
}
frame.setVisible(true) ;
}
}
I prepared a manifest.txt file in D:\jarConcepts with following text :
Main-Class: Demo
Class-Path: C:\Program Files\MySQL\MySQL Tools for 5.0\java\lib\mysql-connector-java-5.0.4-bin.jar
when, i create a jar file from the same directory using
jar -cvfm Demo.jar manifest.txt .class
following is the output :
added manifest adding: Demo.class(in = 743) (out= 505)(deflated 32%)
But, when i execute the jar file generated, it shows an error message,
Could not find the main class. Program will exit.
i don't understand why this is happening, coz, when i creating the jar file with the following manifest code :
Main-Class: Demo
i am getting a perfectly executable Demo.jar, the only problem is that it is not loading the Driver class from the ] class path and when i am trying to add the path in the manifest, it's not working...... plz help.......