aspose file tools*
The moose likes Beginning Java and the fly likes Unable to set the classpath variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Unable to set the classpath variable" Watch "Unable to set the classpath variable" New topic
Author

Unable to set the classpath variable

Mansi Agarwal
Ranch Hand

Joined: Apr 11, 2012
Posts: 53
I just installed jdk6 and set the classpath variable. My javac command is working fine but when I am using "java aa.java" command then it says file not found error.
Please help. Thanks
Kumar Barun
Greenhorn

Joined: Oct 14, 2011
Posts: 20
To launch java class file, be where your class file is and don't do "java aa.java" rather do "java aa". aa will be your class name.
Mansi Agarwal
Ranch Hand

Joined: Apr 11, 2012
Posts: 53
I think the problem is with classpath. Because when I enter javac aa.java .. It says javac is not an internal or external command.
Can you please explain me how to set classpath variable.
Thanks for the reply though.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Mansi Agarwal wrote:I think the problem is with classpath. Because when I enter javac aa.java .. It says javac is not an internal or external command.


That has nothing to do with classpath. Classpath is how the JVM finds class files once it's already running.

Your problem has to do with PATH. The PATH variable is how the command shell finds executables.

Can you please explain me how to set classpath variable.


A web search should turn up plenty of examples of both path and classpath. Note, however, that it's generally better not to set the CLASSPATH environment variable at all, but instead just use the -cp or -classpath argument on the command line when invoking java.
Ravikanth thota
Greenhorn

Joined: Apr 09, 2012
Posts: 24
C:\Program Files\Java\jdk1.6.0_30\bin (copy the path where you jdk\bin is located) ----> right click on mycomputer click on properties ---> click on advanced ----> click on environment variables---->
select path from the second area shown in dialouge box ----> click on edit----> paste the path which you copied in first step at the begining seperated by ; ..

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39834
    
  28
We have an FAQ which covers these questions.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Unable to set the classpath variable