File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes seting the classpath 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 "seting the classpath" Watch "seting the classpath" New topic
Author

seting the classpath

Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
Guys,

For some reason, after I'm installing my JRE, the class path is not set automatically.
When I type javaw on the prompt (c:\>javaw) I get the error message �not recognize as an internal or external command.


I tried in the environment variables � system variable �
And on the variable name: classpath
Variable value: C:\Program Files\Java\j2re1.4.2_09\bin;


This didn�t work.
Does anyone know how to set the classpath correctly?

Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

Peter,
The classpath is used when compiling/running. The path itself is used to find the java/javac/javaw commands. So check the bin directory is in your path environment variable too.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

The error "not recognize as an internal or external command" means that Windows can't find javaw.exe, not that Java can't find classes (which is what CLASSPATH is for.) Windows uses a different environment variable named PATH to find programs. The JDK "bin" directory does not belong on the CLASSPATH, but it does belong on the PATH.

The very best setting for CLASSPATH for a new Java user is -- by a wide margin -- to not have it set to anything at all. The default is just perfect.


[Jess in Action][AskingGoodQuestions]
Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
"but it does belong on the PATH"

well, I can't compile and run anything because there is no access to the bin. how can i set it? I can compile it only from the bin, but I would like to compile it from a different folder.

thank you both for your quick reply
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
You need to add the bin directory to the PATH variable. As noted above, this problem has nothing to do with the CLASSPATH variable. For instructions on how to do this, see step 5 in Sun's Installation Instructions.

Layne


Java API Documentation
The Java Tutorial
Amulya Green
Greenhorn

Joined: Dec 28, 2005
Posts: 19
I think you need to set the path to the bin directory
Good luck
Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
thank you all it works.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: seting the classpath
 
Similar Threads
Oh classpath, why do you hate me?
javaw and bat files
Modifying existing jar file, how?
Need help in installing J2EE
question on package and classpath