This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Do you have a CLASSPATH variable set? if so, what is it set to?
Note: I am not suggesting that you SHOULD have one set. Often, for beginners, it is better to NOT have it, but if you do it could be causing issues.
Joined: Jan 13, 2013
Thanks all for your kind responses
The classpath for java has been set as
C:\Program Files\Java\jdk1.6.0 -- > This causes the issue if i dont`t put semicolon at the end, than i am unable to find my java environment on command prompt by simply giving the command
and Ritche Sir,
I haven`t omitted the package name of my program.
Actually I haven`t kept it in any package nor even in default.
As being new to java, for now i am not using any of the IDs. I am working with NotePad++.
The program is as it is I checked it again.
Its executing for now. Not only this program other basic programs are also executing successfully but the issue is just with the run time
where i have to specify the full path of the location using :
java -cp D:/JAVAPROGAM Light rather than simple command
Jdinesh Tiwari wrote:The classpath for java has been set as
That's wrong. The bin directory of the JDK does not normally contain Java class files. You should not put it in the classpath. (Note: You should add the bin directory of the JDK to the PATH, but not to the CLASSPATH).
Actually, it's better to not set the CLASSPATH environment variable at all. If it is not set, Java will by default use the current directory "." as the classpath.
Java looks in the C:\apache-tomcat-7.0.27\lib\servlet-api.jar directory, can't find your .class file, and reports as such. When you say
java -cp D:/JAVAPROGM Light
you are explicitly saying to it "Look in the D:/JAVAPROGM directory" (i'm not sure if it still looks in the CLASSPATH dirs as well).
So, you have a couple options.
1) ADD the "D:/JAVAPROGM" directory to your classpath.
2) cd into the D:/JAVAPROGM directory before you run "java Light" - although you probably still need to add the dot to your CLASSPATH, saying "use the current directory".
3) get rid of the CLASSPATH all together (although this could break other things) and CD to your D:/JAVAPROGM directory.