running a class which use an external.jar

W

wasabii

Hi all,
I have a class called myclass.class which is calling others classes in
external.jar file.

the external.jar and myClass.class are both in my classpath, however java
is not able to found the jar

1) java myClass ==> failed
2) java -cp external.jar myClass ==> failed

Note that myClass is not in the external.jar.

Accoring my understanding as both are in my classpath that shoud work
(example 1) right ?

Any idea ?

Thanks for you support,
Charlie
 
A

Andrew Thompson

wasabii said:
Hi all,
I have a class called myclass.class

This should be named MyClass if you are following the usual
naming conventions, but I do not advise *ever* giving a class
such a generic (and stupid) name.
...which is calling others classes in
external.jar file.

the external.jar and myClass.class

Above you stated 'myclass', now it is 'myClass'? Java is
case sensitive, so stick with the same capitalisation
throughout.
...are both in my classpath, however java
is not able to found the jar

1) java myClass ==> failed

In this one 'external.jar' is not on the classpath, only the
'current directory', which presumably includes myClass/MyClass
2) java -cp external.jar myClass ==> failed

Now 'external.jar' has been put on the classpath, but
the current directory is not.
Accoring my understanding as both are in my classpath that shoud work
(example 1) right ?
No.

Any idea ?

java -cp .;external.jar MyClass

[ BTW - Please always copy/paste your output. ]

Andrew T.
 
K

Knute Johnson

wasabii said:
Hi all,
I have a class called myclass.class which is calling others classes in
external.jar file.

the external.jar and myClass.class are both in my classpath, however java
is not able to found the jar

1) java myClass ==> failed
2) java -cp external.jar myClass ==> failed

Note that myClass is not in the external.jar.

Accoring my understanding as both are in my classpath that shoud work
(example 1) right ?

Any idea ?

Thanks for you support,
Charlie

Charlie:

You probably need .;extenal.jar in your class path. Take a look at a
paper I just did on Java user class path and let me know if it is any help.

http://rabbitbrush.frazmtn.com/classpath.html
 

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

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top