File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes JDK setup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JDK setup" Watch "JDK setup" New topic

JDK setup

Ranch Hand

Joined: Apr 04, 2007
Posts: 188
what is the command to set the environment variable in my computer to set JDK?
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
For Windows?

You probably want to set the path variable to include the bin folder of the JDK, and set the classpath variable to include your programs.

The path never changes (unless you want to switch between JDKs) so it's safe to set it in the system. In Windows, start / settings / control panel / system / advanced / environment variables button. Then add the full path to the bin directory to the path.

I change the classpath often depending on the program I'm running. I often have a batch file just for one program that adds the necessary jars and other projects I'm working with. For simple exercise programs, it may be enough to have "." in the classpath for current directory, so make sure the "." is in the system defined classpath.

See if this tutorial makes things clearer or worse. Follow the link at the beginning to Sun's setup pages.
[ July 18, 2007: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Ajay Divakaran

Joined: Jul 08, 2007
Posts: 22
I set the path variable to the bin directory ie D:\Program Files\Java\jdk1.6.0\bin and JAVA_HOME to the parent folder ie D:\Program Files\Java\jdk1.6.0\
I can successfully compile my program using javac but when i run it using java it always gives me some class error!!
I've tested it with some basic programs such as only a single println statement but it does'nt run.
But, it works fine from within the java's bin folder when the .class file is present there!
I agree. Here's the link:
subject: JDK setup
It's not a secret anymore!