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 Setting an Entry Point with JAR Tool 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 » Beginning Java
Bookmark "Setting an Entry Point with JAR Tool" Watch "Setting an Entry Point with JAR Tool" New topic
Author

Setting an Entry Point with JAR Tool

Graeme Byers
Ranch Hand

Joined: Apr 16, 2004
Posts: 127
Here is the reference : http://java.sun.com/docs/books/tutorial/deployment/jar/appman.html

Two problems :
1. The e optioned mentioned is flagged invalid and on >jar is not listed (1.5).
2. Are they saying :
Main-Class: AClass (if specified) is the JAR's default entry-point (providing that AClass has a main()).
But that any JAR class (MyApp) with main() can be executed from the command line by specifying the e option ? If so, why is MyApp mentioned twice when public MyApp can be in no file other than MyApp.class ?
Thank you.
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 685
Please post the console showing the commandline and the error.
Also post the contents of the manifest file.
Graeme Byers
Ranch Hand

Joined: Apr 16, 2004
Posts: 127
Norm,
You are correct to ask for a list of the JAR - it's missing the manifest.
As I was going through this exercise I backed up my JAR and the backup does have a manifest.
How could I have lost it ?

Restore the JAR from backup and continue.

Greetings.jar :


Greetings.jar manifest :



With this jar I can run Message.class which contains a main()
>javac -jar Greetings.jar.
But using the e option I want to run Hi.class (also has main()) instead.
Is that what the e option is supposed to do ?

>jar evf Greetings\jar Hi Hi.class 2> JarError.doc



Thank you
Graeme Byers
Ranch Hand

Joined: Apr 16, 2004
Posts: 127
Oops , should be
>jar evf Greetings.jar Hi Hi.class 2> JarError.doc
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 685
Are you using jar version 1.6?
The 'e' flag (for 'entrypoint'), introduced in JDK 6,
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19538
    
  16

You can always just include the JAR file as part of the classpath, then call the absolute class name:

Note that I included the current CLASSPATH contents (although that shouldn't be necessary since java -jar also ignores the class path).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Graeme Byers
Ranch Hand

Joined: Apr 16, 2004
Posts: 127
Thank you,
I am using Java 1.5 and did not know that e option introduced with 1.6.
Graeme Byers
Ranch Hand

Joined: Apr 16, 2004
Posts: 127
Hi Rob,
I believe that if you want to include a JAR in the classpath it cannot be comressed. Code -0 (zero) option for no compression.
Thank you.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19538
    
  16

Sure it can be compressed, I do that a lot of the time. In fact, almost every library I have on the class path is in a compressed JAR file.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting an Entry Point with JAR Tool
 
Similar Threads
desktop applications
about executable jar
How to run jar file
jar classpath
double click and run ?