The JDK has a number of tools which are used in day to day Java coding. Here is a list of some of such tools :
a) javac - The Java Compiler (which converts our source code into machine executable code)
b) java - The Java Interpreter (which runs our code line by line)
c) javadoc - To make the HTML documentation of our code
d) jar - To create the Java Archive (jar) file for our code
e) javap - To disassemble a class file
These tools are present in C:\Program Files\Java\jdk1.[your version]\bin (or C:\Program Files(x86)\Java\jdk1.[your version]\bin). We need some of these tools (like javac & java) again and again to compile and run our code. For this reason we set the path environment to point to this folder so that we can use all its tools from anywhere in our computer.
There are two methods to do so:
a) Using System Properties (Easy)
b) Using Command Line (Medium)
a) Using System Properties
i) Go to C:\Program Files\Java\jdk1.[your version]\bin and copy this path from the address bar.
ii) Right Click on Computer (or My Computer) present on desktop and click on Properties.
iii) Click on Advanced System Settings in the left hand pane (or Advanced tab in case of Windows XP).
iv) Click on Environment Variables.
v) Under the System variables look for a variable named path.
vi) Click on Edit.
vii) In the variable value text field do not delete the stuff which is already present but just add a ; in the end.
viii) Now paste the path (C:\Program Files\Java\jdk1.[your version]\bin) you earlier copied after the ;
ix) Click on OK. OK again and OK yet again and you're done.
b) Using Command Line
i) Press Window Key + R and type cmd to Open Command Prompt.
ii) Type the following command :
setx path "%path%;C:\Program Files\Java\jdk1.[your version]\bin"
iii) You're done with editing your path variable.
Note: [your version] means your JDK version for example if your JDK version is 1.7.0 update 25 then the full path will be C:\Program Files\Java\jdk1.7.0_25\bin. So replace every instance of [your version] by your actual folder name of JDK.
a) javac - The Java Compiler (which converts our source code into machine executable code)
b) java - The Java Interpreter (which runs our code line by line)
c) javadoc - To make the HTML documentation of our code
d) jar - To create the Java Archive (jar) file for our code
e) javap - To disassemble a class file
These tools are present in C:\Program Files\Java\jdk1.[your version]\bin (or C:\Program Files(x86)\Java\jdk1.[your version]\bin). We need some of these tools (like javac & java) again and again to compile and run our code. For this reason we set the path environment to point to this folder so that we can use all its tools from anywhere in our computer.
There are two methods to do so:
a) Using System Properties (Easy)
b) Using Command Line (Medium)
a) Using System Properties
i) Go to C:\Program Files\Java\jdk1.[your version]\bin and copy this path from the address bar.
ii) Right Click on Computer (or My Computer) present on desktop and click on Properties.
iii) Click on Advanced System Settings in the left hand pane (or Advanced tab in case of Windows XP).
iv) Click on Environment Variables.
v) Under the System variables look for a variable named path.
vi) Click on Edit.
Click to Enlarge |
vii) In the variable value text field do not delete the stuff which is already present but just add a ; in the end.
viii) Now paste the path (C:\Program Files\Java\jdk1.[your version]\bin) you earlier copied after the ;
ix) Click on OK. OK again and OK yet again and you're done.
b) Using Command Line
i) Press Window Key + R and type cmd to Open Command Prompt.
ii) Type the following command :
setx path "%path%;C:\Program Files\Java\jdk1.[your version]\bin"
iii) You're done with editing your path variable.
Note: [your version] means your JDK version for example if your JDK version is 1.7.0 update 25 then the full path will be C:\Program Files\Java\jdk1.7.0_25\bin. So replace every instance of [your version] by your actual folder name of JDK.