Results 1 to 17 of 17
Thread: Exporting to an Excutable Jar
- 11-29-2011, 12:46 AM #1
Member
- Join Date
- Nov 2011
- Posts
- 11
- Rep Power
- 0
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:
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)Manifest-Version: 1.0
Class-Path: .
Main-Class: GameLogic.Chess
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
- 11-29-2011, 12:50 AM #2
Re: Exporting to an Excutable Jar
Clearly your classpath is incorrect.
- 11-29-2011, 12:55 AM #3
Member
- Join Date
- Nov 2011
- Posts
- 11
- Rep Power
- 0
Re: Exporting to an Excutable Jar
Ok. How can I correct this?
- 11-29-2011, 01:21 AM #4
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,619
- Rep Power
- 5
Re: Exporting to an Excutable Jar
Cross posted at Exporting to an Excutable Jar
- 11-29-2011, 01:30 AM #5
Re: Exporting to an Excutable Jar
That is very strange. How can the same jar file work on one computer and not on another???I have taken the Jar and put it on another computer and it ran fine
What is different between the machines where it works and where it does not work?
- 11-29-2011, 01:34 AM #6
Member
- Join Date
- Nov 2011
- Posts
- 11
- Rep Power
- 0
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.
- 11-29-2011, 01:37 AM #7
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?
- 11-29-2011, 01:41 AM #8
Member
- Join Date
- Nov 2011
- Posts
- 11
- Rep Power
- 0
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.
- 11-29-2011, 01:42 AM #9
Member
- Join Date
- Nov 2011
- Posts
- 11
- Rep Power
- 0
Re: Exporting to an Excutable Jar
Also, I can get all my computers to run it from eclipse.
- 11-29-2011, 01:49 AM #10
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.
- 11-29-2011, 01:52 AM #11
Member
- Join Date
- Nov 2011
- Posts
- 11
- Rep Power
- 0
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)
- 11-29-2011, 01:54 AM #12
Member
- Join Date
- Nov 2011
- Posts
- 11
- Rep Power
- 0
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)
- 11-29-2011, 02:04 AM #13
Re: Exporting to an Excutable Jar
The java source files were compiled by java 1.7 and you are trying to execute them with an older version.Unsupported major.minor version 51.0
In a command prompt enter: java -version
to see what version of the java command you are using.
- 11-29-2011, 02:07 AM #14
Member
- Join Date
- Nov 2011
- Posts
- 11
- Rep Power
- 0
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.
- 11-29-2011, 02:12 AM #15
Re: Exporting to an Excutable Jar
Its interesting that the external error message is a bit misleading.
- 11-29-2011, 02:23 AM #16
Member
- Join Date
- Nov 2011
- Posts
- 11
- Rep Power
- 0
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.
- 11-29-2011, 02:24 AM #17
Similar Threads
-
making excutable with visual cafe
By robbierut in forum New To JavaReplies: 3Last Post: 12-21-2010, 11:24 AM -
Database With netbeans excutable jar
By amitabh in forum NetBeansReplies: 2Last Post: 06-02-2010, 01:52 PM -
Exporting jar problem
By cocorota in forum EclipseReplies: 0Last Post: 11-20-2009, 05:08 PM -
[SOLVED] creating excutable jar file
By sandeepsai39 in forum New To JavaReplies: 2Last Post: 02-25-2009, 07:43 AM -
[SOLVED] Making JAVA Program excutable
By kirly in forum Advanced JavaReplies: 10Last Post: 10-07-2008, 03:57 AM


5Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks