Two Laptop Bag
The moose likes Beginning Java and the fly likes Installing JDK & PATH Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Installing JDK & PATH" Watch "Installing JDK & PATH" New topic

Installing JDK & PATH

Mark Henryson
Ranch Hand

Joined: Jul 11, 2005
Posts: 200

I am very much interested in learning Java. I am practising lots of programs in my home. In office, in the free time I want to practise some progrmas. So that I downloaded the JDk 15. and I couldn't install it, due to administration doesn't allow it.

However, I succesffully installed it. I copied the JDK1.5 folder(which includes bin folder) from the home and copied in one of my folders in the office. While I am compiling and running the java files by keeping it in the bin folder, it it compiling and running.

I want to add the environment variable. Can I add that variable in Control Panel >> system >> advanced >> environment variables. Whether by adding the path, it will give any other problem to the system. We are using Windows XP professional Edition.

I want to practise some java programs in the free time without causing any damage or interrupt to the machine at office.

Please advice me regd this.
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
This is not really a Java question, but yes - as a regular (non-admin) user you should be able to change the user environmental variables but not the system ones. Add a path variable for your own user and it will be used in addition to the system PATH variable.
Rick O'Shay
Ranch Hand

Joined: Sep 19, 2004
Posts: 531
Skip setting the CLASSPATH. That can be a security risk and a source of bugs. Use the -classpath switch.

javac -d bin
java -classpath bin Test

Another example of compiling something in one folder and putting the class in another and then running it. Note that you should use forward slashes in your classpath but either will work.

javac -d /sandbox/bin /sandbox/src/

java -classpath /sandbox/bin Test

In this example you need a jar to run and to compile. In that case you specify the jar itself not just the folder it lives in as you do using classes.

javac -d /sandbox/bin -cp /acme/rocket.jar /sandbox/src/
java -cp /acme/rocket.jar:sandbox/bin Test

I used the abbreviated cp instead of classpath that time. Also note that each item in the path must be separated with a colon or a semicolon when using Windows.
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
My bad - I interpreted the original post as wanting to change the PATH variable, not the CLASSPATH. Yes, I agree with Rick - setting the classpath variable is a bad idea in many situations.
I agree. Here's the link:
subject: Installing JDK & PATH
It's not a secret anymore!