How to set path

When we compile and run the Java Application then we need setting the path before compile and running the application. These are follwing two ways to set path of JDK:
  1. temporary
  2. permanent
Setting Temporary Path of JDK
  • Go to run prompt
  • Type cmd and press enter
  • Copy the path of bin folder
  • Paste in command prompt: set path=copiedpath

For Example:

set path=C:\Program Files\Java\jdk1.6.0_11\bin

how to set path in java
Setting Permanent Path of JDK for Windows OS
  • Go to MyComputer and press right mouse
  • Select properties option
  • Click on advanced tab
  • Click on environment variables
  • Click on new tab of user variable
  • write path in variable name
  • Copy the path of bin folder
  • paste path of bin folder in variable value
  • ok
  • ok
  • ok

For Example:

1)Go to MyComputer and press right mouse
how to set path in java
 
2)Select properties option
how to set path in java
 
3)Click on advanced tab
 
how to set path in java
 
4)Click on environment variables
how to set path in java
 
4.1)Click on new tab of user variables
how to set path in java
 
5)Write path in variable name
how to set path in java
 
6)Copy the path of bin folder
how to set path in java
 
7)Paste path of bin folder in variable value
how to set path in java
 
8)Click on ok button
how to set path in java

Now permanent path is set.

Setting path of JDK in Linux OS

Setting java path(In Temporary way)

#JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk

#export $JAVA_HOME

Setting java path (In Permanent way)

Edit ~/.bashrc and place below two lines in that file and save the file.

Vi ~/.bashrc
JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk export $JAVA_HOME

Now save the file and exit, then logout and login to make those changes to reflect.

Command

/usr/lib/jvm/jre-1.6.0-openjdk/bin/java

 



 

Latest Tutorial


Most Visited Tutorial