Running a class from inside a jar

D

Derek Fountain

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
fine.

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?
 
T

Thomas Weidenfeller

Joined
Sep 29, 2011
Messages
1
Reaction score
0

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top