How to make executetable jar file? if not setting the classpath?
I read some website teaching how to make a executable jar file
my question is how to create a executable jar file with specify the file path
================================================
A simple example. Let's say we wanted to distribute the simple program Hello.java as a JAR. First, we create a text file named Hello.mf which contains:
Manifest-Version: 1.0
Main-Class: Hello
Then, we create the archive by typing:
jar cmf Hello.mf Hello.jar Hello.class Hello.java
and run it by typing:
java -jar Hello.jar
=================================================
then I try to do this
success to make jar and jar can be run anywhere
====================================================
C:\>cd Hello
C:\Hello>c:\j2sdk1.4.2_04\bin\jar cvfm c:\Hello\Hello.jar c:\Hello\META-INF\MANI
FEST.MF *.class
added manifest
adding: Hello.class(in = 401) (out= 276)(deflated 31%)
C:\Hello>c:\j2sdk1.4.2_04\jre\bin\java -jar c:\Hello\Hello.jar
Hello
C:\Hello>d:
D:\>c:\j2sdk1.4.2_04\jre\bin\java -jar c:\Hello\Hello.jar
Hello
=====================================================
It's need to go into the Hello directory to create the jar file!!
my question is if I do not enter to Hello directory. How to specify the command ??
I have try to make the jar outside the Hello directory It make the jar also but exception found
Exception in thread "main" java.lang.NoClassDefFoundError: Hello
thx!
newbie
Last edited by antony_csf; 06-29-2004 at 01:35 AM.
|