Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Installing JDK & PATH

 
Mark Henryson
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Skip setting the CLASSPATH. That can be a security risk and a source of bugs. Use the -classpath switch.

javac -d bin Test.java
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/Test.java

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/Test.java
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
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic