how to create a executable jar file in java??
Printable View
how to create a executable jar file in java??
Use the jar command that comes with the jdk
http://docs.oracle.com/javase/tutori...jar/index.html
i hv created a jar file but it wont work..everytime i run it it says cannot find main class the program will exit now...what to do now??pls helppp...
Please copy the full text of the error message and paste it here.
What is in the manifest file that is in the jar file?
What are the locations/paths to the class files in the jar file?
the contents of the manifest file is as follows:
"Main-Class: main"(main is the name of the class which contains the static void main class...)
the error message is as follows:
"failed to load Main-Class manifest attribute from main.jar"
the path of the class files are the same as of the jar file..both are created in the same directory...!!!!
Some confusion here. Class names should start with uppercase letters
The class should have a main() method. Not a class.Quote:
the static void main class
Is the Main class in a package?
Is there a newline character after the classname on the Main-Class: line?
ok thr nw line charctr was posin sum hindranc...i gt it fixed..thnkssss...nw another problem...jar file has been created n is runnin fine in ma system...but when ported to anothr system it jus doesnt budge...says.."failed to load main method"..
is it because of the jdk version conflict???pls helpp
Can you get the full text of the error message:
Open a command prompt window, change to the folder with the jar file and enter:
java -jar THEJARFILENAME.jar
copy the contents of the command prompt window and paste it here.
C:\>java -jar bdb.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version n
umber in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknow n Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Did you compile the class file with version 1.7 and try to execute it with version 1.6?
1.6 can not execute class files from 1.7
no...actuaallyy i did a lill somthn similiar...i complied with version 1.6 n try n execute wid version 1.5!!!!
That would cause the same version incompatibility problem.