jar help  
Author Message
SP





PostPosted: 2003-6-28 20:44:00 Top

java-programmer, jar help hi
i have been trying to make a jar file for the following files

hello.java
hello.class
with the following command

jar cf hello.jar hello.*

it is created and with
jar tf hello.jar

i am able to see the list of files which is in this case
META-INF/
META-INF/MANIFEST.MF
hello.class
hello.java

but it doesn't run with
java -jar hello.jar

following error appears
Failed to load Main-Class manifest attribute from
hello.jar

i tried to fix it with

jar cfm hello.jar mymainclass hello.*(after creating mymainclass with the
entry Main-Class: path.hello)

to no avail!
and another thing is although the dir META-INF is shown as above it is not
created in the folder..where is it created??

help please

Greetingz
Sunil


 
Haakon Nilsen





PostPosted: 2003-6-28 21:27:00 Top

java-programmer >> jar help SP wrote:

> i tried to fix it with
>
> jar cfm hello.jar mymainclass hello.*(after creating mymainclass with the
> entry Main-Class: path.hello)

Is the class hello in the package path? If it's not in any package, just
use "Main-Class: hello".

(Btw, class names in java should be capitalized, so use Hello instead of
hello for the class name.)

> to no avail!
> and another thing is although the dir META-INF is shown as above it is not
> created in the folder..where is it created??

The jar program creates that directory, you need not worry about it.

 
ghl





PostPosted: 2003-6-28 23:51:00 Top

java-programmer >> jar help "SP" <email***@***.com> wrote in message
news:l4gLa.43143$email***@***.com...
> hi
> i have been trying to make a jar file for the following files
>
> hello.java
> hello.class
> with the following command
>
> jar cf hello.jar hello.*
>
> it is created and with
> jar tf hello.jar
>
> i am able to see the list of files which is in this case
> META-INF/
> META-INF/MANIFEST.MF
> hello.class
> hello.java
>
> but it doesn't run with
> java -jar hello.jar
[Assuming all your files are in the same directory...]
To run the application from a jar file by specifying the jar (hello.jar) the
jar file manifest.mf file must contain a header of the form
Main-Class: start-classname
This tells Java which class to load and call first.
You can modify the manifest.mf file in the jar by creating a file with the
needed header and updating the jar file using the jar command uvfm.
The file you need would be something like myMan.txt and would contain the
line
Main-Class: hello
The jar update would be
jar uvfm hello.jar myMan.txt
This will update the jar with the header in myMan.txt

You can then run the app with
java -jar hello.jar

By putting the jar file in the JAVA_HOME\jre\lib\ext directory you can run
the app with
java hello
from anywhere.
Have fun.

 
 
hh





PostPosted: 2003-6-29 2:05:00 Top

java-programmer >> jar help SP wrote:
> hi
> i have been trying to make a jar file for the following files
>
> hello.java
> hello.class
> with the following command
>
> jar cf hello.jar hello.*
>
> it is created and with
> jar tf hello.jar
>
> i am able to see the list of files which is in this case
> META-INF/
> META-INF/MANIFEST.MF
> hello.class
> hello.java
>
> but it doesn't run with
> java -jar hello.jar
>
> following error appears
> Failed to load Main-Class manifest attribute from
> hello.jar
>
> i tried to fix it with
>
> jar cfm hello.jar mymainclass hello.*(after creating mymainclass with the
> entry Main-Class: path.hello)
>
> to no avail!
> and another thing is although the dir META-INF is shown as above it is not
> created in the folder..where is it created??
>
> help please
>
> Greetingz
> Sunil
>
>

To add to the other two responses, you might find a tool such as JavaJar
useful: http://pivotonic.com/


 
 
Liu, Chunyen





PostPosted: 2003-6-30 21:53:00 Top

java-programmer >> jar help use "jar cvf hello.jar hello.class"
There is no need to include the source code (*.java)

> -----Original Message-----
> From: SP [SMTP:email***@***.com]
> Posted At: Saturday, June 28, 2003 7:44 AM
> Posted To: comp.lang.java.programmer
> Conversation: jar help
> Subject: jar help
>
> hi
> i have been trying to make a jar file for the following files
>
> hello.java
> hello.class
> with the following command
>
> jar cf hello.jar hello.*
>
> it is created and with
> jar tf hello.jar
>
> i am able to see the list of files which is in this case
> META-INF/
> META-INF/MANIFEST.MF
> hello.class
> hello.java
>
> but it doesn't run with
> java -jar hello.jar
>
> following error appears
> Failed to load Main-Class manifest attribute from
> hello.jar
>
> i tried to fix it with
>
> jar cfm hello.jar mymainclass hello.*(after creating mymainclass with
> the
> entry Main-Class: path.hello)
>
> to no avail!
> and another thing is although the dir META-INF is shown as above it is
> not
> created in the folder..where is it created??
>
> help please
>
> Greetingz
> Sunil
>