how to create a executable jar file in java??
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
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
If you don't understand my answer, don't ignore it, ask a question.
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?
If you don't understand my answer, don't ignore it, ask a question.
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.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?
If you don't understand my answer, don't ignore it, ask a question.
amber_hell (March 3rd, 2013)
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.
If you don't understand my answer, don't ignore it, ask a question.
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
If you don't understand my answer, don't ignore it, ask a question.
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.
If you don't understand my answer, don't ignore it, ask a question.
amber_hell (March 7th, 2013)