Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to set the classpath variable

 
Mansi Agarwal
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have an FAQ which covers these questions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic