• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting an Entry Point with JAR Tool

 
Graeme Byers
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 885
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post the console showing the commandline and the error.
Also post the contents of the manifest file.
 
Graeme Byers
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops , should be
>jar evf Greetings.jar Hi Hi.class 2> JarError.doc
 
Norm Radder
Ranch Hand
Posts: 885
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using jar version 1.6?
The 'e' flag (for 'entrypoint'), introduced in JDK 6,
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Graeme Byers
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you,
I am using Java 1.5 and did not know that e option introduced with 1.6.
 
Graeme Byers
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic