Results 1 to 17 of 17
Like Tree5Likes
  • 1 Post By Norm
  • 1 Post By Norm
  • 1 Post By Norm
  • 1 Post By Norm
  • 1 Post By Norm

Thread: Exporting to an Excutable Jar

  1. #1
    KeyLay is offline Member
    Join Date
    Nov 2011
    Posts
    11
    Rep Power
    0

    Default Exporting to an Excutable Jar

    I am not quite new to Java, but I am having a problem with exporting to a jar file. It is really frustrating because I have other files that have been exported the same way that work fine. But here is my problem. I can run my problem fine in Eclipse. It works great. Now, I want to share it with the world (or a few friends), however I am having problems doing this.

    It gives me the error: "Could not find the main class: GameLogic.Chess. Program will now exit"

    This is what I have tried. Looking at the MAINFEST.MF file inside the jar. It looks like this:

    Manifest-Version: 1.0
    Class-Path: .
    Main-Class: GameLogic.Chess
    So that looks right. I have reinstalled Eclipse and Java. I have taken the Jar and put it on another computer and it ran fine, but when I took it to another machine that was imaged from the other one it got the same error I am receiving. (weird)

    I have tried the plug-in fatjar and I get the same result.

    I have taken the program apart and commented everything out but the JFrame. Still doesn't work. I don't know what to try next. So I figured I would try to ask a community if they knew about anything else I could try.

    Thanks,

    KeyLay

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default Re: Exporting to an Excutable Jar

    Clearly your classpath is incorrect.

  3. #3
    KeyLay is offline Member
    Join Date
    Nov 2011
    Posts
    11
    Rep Power
    0

    Default Re: Exporting to an Excutable Jar

    Ok. How can I correct this?

  4. #4
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: Exporting to an Excutable Jar


  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,390
    Rep Power
    25

    Default Re: Exporting to an Excutable Jar

    I have taken the Jar and put it on another computer and it ran fine
    That is very strange. How can the same jar file work on one computer and not on another???

    What is different between the machines where it works and where it does not work?
    KeyLay likes this.

  6. #6
    KeyLay is offline Member
    Join Date
    Nov 2011
    Posts
    11
    Rep Power
    0

    Default Re: Exporting to an Excutable Jar

    The strange thing is I created it on my notebook. Windows 7 64 bit. No good. Then I have an XP computer and it works fine (same file). Took it to an imaged computer to the XP machine and no joy. Take it to my mac, and it works. It is getting frustrating.

  7. #7
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,390
    Rep Power
    25

    Default Re: Exporting to an Excutable Jar

    Are the error messages the same on the PCs where it does not work?
    What versions of java are involved?
    KeyLay likes this.

  8. #8
    KeyLay is offline Member
    Join Date
    Nov 2011
    Posts
    11
    Rep Power
    0

    Default Re: Exporting to an Excutable Jar

    Every machine with the exception of the mac is running the latest JDK 1.7. The only error message I receive is "Could not find the main class: GameLogic.Chess. Program will now exit" Which is the correct name of where my main class is located.

  9. #9
    KeyLay is offline Member
    Join Date
    Nov 2011
    Posts
    11
    Rep Power
    0

    Default Re: Exporting to an Excutable Jar

    Also, I can get all my computers to run it from eclipse.

  10. #10
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,390
    Rep Power
    25

    Default Re: Exporting to an Excutable Jar

    No ideas. If the same jar file works here and not there and where it does not work it reads the manifest file from th e jar file, I can not think of how that can be.
    What is the Class-Path: . entry for? Are there other files the program reads from the current directory?

    On a PC where it does not work could you open a command prompt, change to the folder with the jar file and enter the command: java -jar <YOURJARFILENAME>.jar
    Copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.

    Be sure to come back and let us know when you get it to work.
    KeyLay likes this.

  11. #11
    KeyLay is offline Member
    Join Date
    Nov 2011
    Posts
    11
    Rep Power
    0

    Default Re: Exporting to an Excutable Jar

    That was helpful. I got this so far. This gives me a whole new range of things to try now.

    Exception in thread "main" java.lang.NoClassDefFoundError: chess/jar
    Caused by: java.lang.ClassNotFoundException: chess.jar
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 47)

  12. #12
    KeyLay is offline Member
    Join Date
    Nov 2011
    Posts
    11
    Rep Power
    0

    Default Re: Exporting to an Excutable Jar

    I can't follow directions. That was for java chess.jar. This is for java -jar chess.jar

    java -jar chess.jar
    Exception in thread "main" java.lang.UnsupportedClassVersionError: GameLogic/Chess : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader. java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java :615)
    at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader .java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader. java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 47)

  13. #13
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,390
    Rep Power
    25

    Default Re: Exporting to an Excutable Jar

    Unsupported major.minor version 51.0
    The java source files were compiled by java 1.7 and you are trying to execute them with an older version.
    In a command prompt enter: java -version
    to see what version of the java command you are using.
    KeyLay likes this.

  14. #14
    KeyLay is offline Member
    Join Date
    Nov 2011
    Posts
    11
    Rep Power
    0

    Default Re: Exporting to an Excutable Jar

    Thank you so much Norm. You really helped me out. I changed the library's in eclipse to use both JDK 1.7 and 1.6 and that seems to work great.

  15. #15
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,390
    Rep Power
    25

    Default Re: Exporting to an Excutable Jar

    Its interesting that the external error message is a bit misleading.
    KeyLay likes this.

  16. #16
    KeyLay is offline Member
    Join Date
    Nov 2011
    Posts
    11
    Rep Power
    0

    Default Re: Exporting to an Excutable Jar

    Thank you so much. My friends and I can now play weird chess variants we thought would be fun to create. Now to see if this problem was worth the time and effort I put into it.

  17. #17
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,390
    Rep Power
    25

Similar Threads

  1. making excutable with visual cafe
    By robbierut in forum New To Java
    Replies: 3
    Last Post: 12-21-2010, 11:24 AM
  2. Database With netbeans excutable jar
    By amitabh in forum NetBeans
    Replies: 2
    Last Post: 06-02-2010, 01:52 PM
  3. Exporting jar problem
    By cocorota in forum Eclipse
    Replies: 0
    Last Post: 11-20-2009, 05:08 PM
  4. [SOLVED] creating excutable jar file
    By sandeepsai39 in forum New To Java
    Replies: 2
    Last Post: 02-25-2009, 07:43 AM
  5. [SOLVED] Making JAVA Program excutable
    By kirly in forum Advanced Java
    Replies: 10
    Last Post: 10-07-2008, 03:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •