Running a class from inside a jar
Newbie one: I have a Hello.class in my local directory which prints "Hello"
and a World.class in ./org/test which prints "World". The World class is in
a package (org.test) which the Hello class imports and calls to. It works
Now I want to put the World class in a JAR. I create the JAR with "jar cf
World.jar World.class" which seems to work properly, but that leaves the
question of where do I put the JAR file and how do I run the JVM such that
it finds the class inside the JAR?
I tried putting the JAR in the local directory and running with a CLASSPATH
set to ., I tried putting the JAR in the org/test directory, I tried
putting the World.jar in the CLASSPATH, and several other permutations, but
I can't find the one that works. Can someone spell it out for me?
Re: Running a class from inside a jar
Derek Fountain wrote:
> Newbie one:
Newbie questions are better handled in comp.lang.java.help.
> Now I want to put the World class in a JAR. I create the JAR with "jar cf
> World.jar World.class" which seems to work properly, but that leaves the
> question of where do I put the JAR file and how do I run the JVM such that
> it finds the class inside the JAR?
Read the documentation:
The comp.lang.java.gui FAQ:
Here is the answer for any googlers who find this thread in the future.
jre -cp app.jar MainClass
|All times are GMT. The time now is 03:51 PM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.