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.

Results 1 to 12 of 12

Thread: jar file

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default jar file

    how to create a executable jar file in java??


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,667
    Thanks
    45
    Thanked 1,960 Times in 1,934 Posts

    Default Re: jar file

    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.

  3. #3
    Junior Member
    Join Date
    Feb 2013
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: jar file

    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...

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,667
    Thanks
    45
    Thanked 1,960 Times in 1,934 Posts

    Default Re: jar file

    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.

  5. #5
    Junior Member
    Join Date
    Feb 2013
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: 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...!!!!

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,667
    Thanks
    45
    Thanked 1,960 Times in 1,934 Posts

    Default Re: jar file

    Some confusion here. Class names should start with uppercase letters
    the static void main class
    The class should have a main() method. Not a 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.

  7. The Following User Says Thank You to Norm For This Useful Post:

    amber_hell (March 3rd, 2013)

  8. #7
    Junior Member
    Join Date
    Feb 2013
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: jar file

    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

  9. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,667
    Thanks
    45
    Thanked 1,960 Times in 1,934 Posts

    Default Re: jar file

    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.

  10. #9
    Junior Member
    Join Date
    Feb 2013
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: jar file

    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)

  11. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,667
    Thanks
    45
    Thanked 1,960 Times in 1,934 Posts

    Default Re: jar file

    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.

  12. #11
    Junior Member
    Join Date
    Feb 2013
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: jar file

    no...actuaallyy i did a lill somthn similiar...i complied with version 1.6 n try n execute wid version 1.5!!!!

  13. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,667
    Thanks
    45
    Thanked 1,960 Times in 1,934 Posts

    Default Re: jar file

    That would cause the same version incompatibility problem.
    If you don't understand my answer, don't ignore it, ask a question.

  14. The Following User Says Thank You to Norm For This Useful Post:

    amber_hell (March 7th, 2013)

Similar Threads

  1. run jar file inside a jar file?
    By ufrubnuckle in forum Java Theory & Questions
    Replies: 1
    Last Post: February 21st, 2013, 05:58 AM
  2. Run a jar file inside a batch file with Windows 7 Task schduler
    By kingnachi in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 15th, 2012, 09:20 AM
  3. [SOLVED] jar file Built(clean and build) perfectly, but not running as jar
    By chronoz13 in forum What's Wrong With My Code?
    Replies: 18
    Last Post: July 11th, 2011, 11:41 AM
  4. Replies: 10
    Last Post: January 12th, 2011, 04:48 AM
  5. Replies: 5
    Last Post: November 13th, 2010, 12:53 PM