This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Another CLASSPATH Problem!!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Another CLASSPATH Problem!!!!" Watch "Another CLASSPATH Problem!!!!" New topic
Author

Another CLASSPATH Problem!!!!

Abhishek Asthana
Ranch Hand

Joined: Sep 08, 2004
Posts: 146
Now this is making me mad.

I have installed java 1.5 Update 8.

My environment variables are:

I am able to compile any program from command line, but when I try to run it using java classname, I get error:
I am able to run some programs only by using java -cp option. Now the problem is that I am not able to run the programs enclosed in jar files. No matter what I am doing, I get the same error.

I have to do this:
java org.apache.axis.client.AdminClient
This compiled class is a part of axis.jar. I tried to run it in two ways.
1)
and then extracted the files from jar file and

2)

But the error comes:

Please help me with this!
Abhishek
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
You normally would not have the bin directory of the JDK in your CLASSPATH unless for some reason you have your source code and .class files in that directory.

The only other things you have in your CLASSPATH are jar files so the interpreter can't find your .class file because the current directory is not in the CLASSPATH.

Try removing the bin directory of the JDK from the CLASSPATH, and appending ;. to the end of the CLASSPATH.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3432
    
  12
If a class is in a jar file, then you have to include the jar file in the classpath. Something like
java -cp axis.jar org.apache.axis.client.AdminClient
[ August 21, 2006: Message edited by: Joanne Neal ]

Joanne
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Another CLASSPATH Problem!!!!
 
Similar Threads
Exception in thread main
classpath of JAR files
Struggling to run code ( java . lang . NoClassDefFoundError: )
Error on deploying the web service
Can not run jsp in tomcat 5.0.19