aspose file tools*
The moose likes Java in General and the fly likes Creating JAR File - Eclipse or otherwise Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Creating JAR File - Eclipse or otherwise" Watch "Creating JAR File - Eclipse or otherwise" New topic
Author

Creating JAR File - Eclipse or otherwise

Tom Finn
Greenhorn

Joined: Apr 15, 2012
Posts: 8
Trying to create an executable JAR file in Eclipse. I'm getting this error:

Could not find the main class my1.first.package.Boot. Program will exit.

To simplify things I created a very basic 1 class program to try and find the problem and get the same result. If I try and do it with the following command line:

jar cf Test.jar Tester.java

I get a new error:

Failed to load Main-Class manifest attribute from C:\Users\Me\Desktop\Project\Test.jar

I'd really like to package this up with Eclipse but any help is much appreciated. I can't figure this one out alone!

Cheers.
Jay Orsaw
Ranch Hand

Joined: Jun 14, 2011
Posts: 356

Tom Finn wrote:Trying to create an executable JAR file in Eclipse. I'm getting this error:

Could not find the main class my1.first.package.Boot. Program will exit.

To simplify things I created a very basic 1 class program to try and find the problem and get the same result. If I try and do it with the following command line:

jar cf Test.jar Tester.java

I get a new error:

Failed to load Main-Class manifest attribute from C:\Users\Me\Desktop\Project\Test.jar

I'd really like to package this up with Eclipse but any help is much appreciated. I can't figure this one out alone!

Cheers.


In Netbeans when I set the main class it is PackageName.ClassName so if "Tester" is your class it would be Package.Tester.... If it's the same in Eclipse you have to find it and set it in the properties.... I right click my node and goto properties, then goto the run section and it says "Main Class." I'll try and find my Eclipse and see if I can help you out from there, but hopefully this helps out a bit. I'm not sure if this is your actual error though, but I know when I have my main set incorrectly, the Jar wont run, and that's what the error seems(I haven't run it from the cmd line...)
Tom Finn
Greenhorn

Joined: Apr 15, 2012
Posts: 8
The Tester class was made without a package so it really is just "Tester". The manifest file all seems in order so I don't understand why it can't find the Main class. I appreciate your help so far!
Tom Finn
Greenhorn

Joined: Apr 15, 2012
Posts: 8
Dear god I'm stupid. My Java runtime environment was massively out of date. Runs perfect first time. Exasperatingly foolish.

Thanks for your help once again, glad I got there in the end.
Jay Orsaw
Ranch Hand

Joined: Jun 14, 2011
Posts: 356

Tom Finn wrote:Dear god I'm stupid. My Java runtime environment was massively out of date. Runs perfect first time. Exasperatingly foolish.

Thanks for your help once again, glad I got there in the end.


Oh yeah I forgot that you have to make sure your version and the jvm version are the same... I use both 6/7 so yeah that happens too... Glad you figured it out.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38765
    
  23
Tom Finn wrote:Dear god I'm stupid. . . .
I’m sure you are mistaken there.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creating JAR File - Eclipse or otherwise