File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes making a .jar - error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "making a .jar - error" Watch "making a .jar - error" New topic
Author

making a .jar - error

Keshan Pillay
Greenhorn

Joined: May 21, 2008
Posts: 29
Good evening everyone,

thanks for looking at my post. I apologise in advance if this is in the wrong place.

I use textpad to write, compile and run my code. I've just finished a simple 2D java game for an assignment. The game runs perfectly when ran from textpad.

The files are located in C:\Keshan Pillay\brick

I used the command:

C:\Keshan Pillay\brick>jar cmf run.txt brick.jar *.*

I have defined my main class in run.txt, and didn't forget the carriage return.

My program contains several (5) .class files, a jpeg, and a MIDI file.
After issuing the command, I open the resulting .jar file with winRAR, and all the files are present, and opening the manifest, the main class has been assigned correctly. However, when I double click the .jar nothing happened. So I read somewhere that I need to change the exe I use to open the .jar. I was told to change the association to javaw.exe to open .jar files. Which I did. Now when I double click on the .jar I get this error:

"Could not find the main class. Program will exit!"

I'm rather confused as to whats happening. I would really appreciate it if anyone could advise me.

Many thanks,
Keshan Pillay
Balasubramanian Chandrasekaran
Ranch Hand

Joined: Nov 28, 2007
Posts: 215

Originally posted by Keshan Pillay:

......
opening the manifest, the main class has been assigned correctly. However, when I double click on the .jar I get this error:

"Could not find the main class. Program will exit!"

I'm rather confused as to whats happening. I would really appreciate it if anyone could advise me.

Many thanks,
Keshan Pillay


I doubt, may be your package hierarchy causes problem

If your main class is inside package bin.class then your manifest file must contain
Keshan Pillay
Greenhorn

Joined: May 21, 2008
Posts: 29
Sorry, me being a beginner, I really didn't understand that...
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Hello Keshan,

Please go through this link.
This may help you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: making a .jar - error