classpath woes

M

Mark Probert

Hi, all.

I am new to Java, though experienced in other languages, and I am not
really getting the CLASSPATH thing. Here is my exact problem:

I am trying to use an SNMP library (from Westhawk). The library tests
run fine and the example code works okay (executed via Ant). Now, I take
the library jar and try and make it work from the command-line. Javac is
not a problem and I get my class files, then create an app jar (called
disp1.jar). My problem comes when I try and run it:

(mark@locke) 11:42 $ java -cp snmp5_1.jar -jar disp1.jar
Exception in thread "main" java.lang.NoClassDefFoundError:
uk/co/westhawk/snmp/stack/AsnOctetsPrintableFace
at java.lang.ClassLoader.defineClass0(Native Method)
<etc.>

Now, that missing class is in the snmp5_1.jar. I can unjar it and see it
in there.

So, what gives? Obviously I am not understanding something here.

Regards,
 
D

Danno

Mark said:
Hi, all.

I am new to Java, though experienced in other languages, and I am not
really getting the CLASSPATH thing. Here is my exact problem:

I am trying to use an SNMP library (from Westhawk). The library tests
run fine and the example code works okay (executed via Ant). Now, I take
the library jar and try and make it work from the command-line. Javac is
not a problem and I get my class files, then create an app jar (called
disp1.jar). My problem comes when I try and run it:

(mark@locke) 11:42 $ java -cp snmp5_1.jar -jar disp1.jar
Exception in thread "main" java.lang.NoClassDefFoundError:
uk/co/westhawk/snmp/stack/AsnOctetsPrintableFace
at java.lang.ClassLoader.defineClass0(Native Method)
<etc.>

Now, that missing class is in the snmp5_1.jar. I can unjar it and see it
in there.

So, what gives? Obviously I am not understanding something here.

Regards,


In the manifest file you need an entry called Class-Path: in addition
to Main-Class:

for more info go here:
http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html

By the way once you have that you can just run:
java -jar disp1.jar

Good Luck and let us know
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top