After installing JDK (download JDK here) we have to set path and classpath variables.
Path variable holds a the path to the executable file javac.exe. Generally this file is located at C:\Program Files\Java\jdk1.6.x\bin. So in order to execute this command we must go to C:\Program Files\Java\jdk1.6.x\bin and execute javac x.java. This is a painful task, so in order to avoid that we must set path variable in the environmental variables.
How to set Environmental Variables :
Right click on My Computer –> Select Properties
Select Advanced system settings
Select Environment Variables.. In the User Variables select PATH and click Edit…
Append C:\Program Files\Java\jdk1.6.0_21\bin (Assuming that Java is installed in C:\Program Files) in the text box and press ok.
If you notice carefully you find javac.exe file located in the path. Now you can issue javac command from any directory.
For more information visit the following link.
http://download.oracle.com/javase/tutorial/essential/environment/paths.html
Hi,
ReplyDeleteIts worth noting that if you have two classes with same name in classpath in that case one which comes earlier in classpath will get picked up. this concept is very useful to test patch releases where you update only few classes to quickly test patch release or have added some debug print statement to troubleshoot any issue. to read more about How classpath works in Java
Thanks
Javin
Why String is immutable in Java