iphone
asked on
how to set classpath jar file while jar in jar file?
for example i have files:
----------------------
mianclass.txt
a.jar
myclass.class
----------------------
mianclass.txt contain:
--------------------------
Main-Class: myclass
-------------------------
and i make a jar file again
-------------------------- ---------- ---------- ---------- -
jar cmf mainclass.txt run.jar myclass.class a.jar
-------------------------- ---------- ---------- ---------- -
so i got file run.jar,and i run the file
-------------------
java -jar run.jar
--------------------
when i run the file it got error like this "Exception in thread "main" java.lang.NoClassDefFoundE rror".
How to set classpath a.jar? it set in mainclass.txt or where?
----------------------
mianclass.txt
a.jar
myclass.class
----------------------
mianclass.txt contain:
--------------------------
Main-Class: myclass
-------------------------
and i make a jar file again
--------------------------
jar cmf mainclass.txt run.jar myclass.class a.jar
--------------------------
so i got file run.jar,and i run the file
-------------------
java -jar run.jar
--------------------
when i run the file it got error like this "Exception in thread "main" java.lang.NoClassDefFoundE
How to set classpath a.jar? it set in mainclass.txt or where?
instead of including a.jar, extract it and include its contents
alternatively don't include a.jar at all and distribute it along with run.jar and specify it using the class-path attibute in your manifest
http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html
http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html
1. mainclass.txt must contain:
--------------------------
Main-Class: myclass
-------------------------
Last blank string is necessary. Make sure that your file named "mainclass.txt", not "mianclass.txt".
2. Use this command for generate JAR file:
jar cfm run.jar mainclass.txt myclass.class a.jar
3. About classpath:
--------------------------
Main-Class: myclass
Class-Path: yourpackage/a.jar
-------------------------
--------------------------
Main-Class: myclass
-------------------------
Last blank string is necessary. Make sure that your file named "mainclass.txt", not "mianclass.txt".
2. Use this command for generate JAR file:
jar cfm run.jar mainclass.txt myclass.class a.jar
3. About classpath:
--------------------------
Main-Class: myclass
Class-Path: yourpackage/a.jar
-------------------------
ASKER
Yozj what you mean
-------------------------- ---------- -
Class-Path: yourpackage/a.jar
-------------------------- ---------- --
"yourpackage" ??
a.jar is in run.jar right, and a.jar and myclass.class at the same lavel.
So what is "yourpackage" mean?
--------------------------
Class-Path: yourpackage/a.jar
--------------------------
"yourpackage" ??
a.jar is in run.jar right, and a.jar and myclass.class at the same lavel.
So what is "yourpackage" mean?
ASKER
objects i dun't want extract a.jar file, because a jar file is jpedal.jar (other library )
If the same level then "Class-Path: a.jar"
ASKER
if i set Class-Path: a.jar, it get a.jar from outside run.jar.
not get a.jar in run.jar.
not get a.jar in run.jar.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thx CEHJ, i think i will use 'OneJar'.. thx again
:-)