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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Run the .jar file" Watch "Run the .jar file" New topic
Author

Run the .jar file

Hamsagayathri Palanisamy
Ranch Hand

Joined: Mar 10, 2008
Posts: 44
Hi all,
When i try to run the .jar file,the following error is thrown.
"Failed to load Main-Class manifest attribute from"
How could i correct the above error.
As i'm very much new to this jar file creation.I tired with
following sample
jar cf sample1.jar GetIP.class
and just i run the .jar as
java -jar sample1.jar

is that rite are something else need to follow?
correct me if i'm wrong.

-Thanks & Regards,
Hamsa
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
You need to put the name of your class with the main method in the jar's manifest file. Read this, particularly the bits about manifest files and setting the entry point.
Hamsagayathri Palanisamy
Ranch Hand

Joined: Mar 10, 2008
Posts: 44
Originally posted by Campbell Ritchie:
You need to put the name of your class with the main method in the jar's manifest file. Read this, particularly the bits about manifest files and setting the entry point.




Thank you campbell. It works fine.

-Thanks & Regards,
Hamsa
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
You're welcome, and well done.
Hamsagayathri Palanisamy
Ranch Hand

Joined: Mar 10, 2008
Posts: 44
one more doubt please
In my jar file named Myjar having the following contents..
under MyPackage

--> MyClass
--> Image file (bmp)

"MyClass" takes "Image file" as input and produce another "Image file" (bmp)as output.
I want to write that output of that "MyClass" to the "Myjar".
How can we do that?is there any possibility?

-Thanks & Regards,
Hamsa
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
Don't know. Probably not, I am afraid. The idea of jar files is to contain executable file and resources. Not for output.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
You can update an existing JAR file like this.



You'll have to try it and see whether the new image.bmp is added to the JAR or overwrites the existing file.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Run the .jar file
 
Similar Threads
JAR Fatal Exception
Using java to run java files Problem
compiling a non packaged class
file upload with jsp
Compiling a java code having different file name and class name