Linux News|Linux Install sidebyside windows|Ubuntu|Linux Help|Installing Apache and php from source

Monday, December 19, 2011

Setting Environment variable for java in ubuntu/Linux

To set environment variable for java proceed as follows:
Firstly goto oracle website and download java development tool kit which is of .bin extension.
Here I am using jdk-6u23-i586.bin file which is downloaded by me .Copy it onto Desktop,open the terminal and do the folllowing:
tarun@chawla~$cd Desktop
tarun@chawla~/Desktop$sudo chmod +x jdk-6u23-i586.bin
A screen shot is given below

After that a directory with some files will be created on your Desktop let call this directory as jdk1.6_23.
Now you have to add the  jdk1.6_23/bin path to PATH enviroment variable as follows.
All executables files are stored in  a directory somewhere which act as a command for you,when you type the file name and press enter it executes.For ex you type mkdir command for making directory,actually mkdir is a executable file stored at some place in directory such as /usr/bin.
Environment Path variable are used to locate commands ,the path for these commands is stored in PATH variable. Now you have to add that jdk/bin path to PATH variable.I have put jdk files on my Desktop so absolute path here will be /home/tarun/Desktop/jdk1.6_23/bin,here tarun is my user name replace it with your username.
Now open the terminal and proceed as follows and this time you are in home directory by typing cd command:
tarun@chawla~$echo $PATH
tarun@chawla~$gedit .bashrc

.bashrc file will be opened which is a text file,and append following line to the file
check your installation by opening terminal again after closing the previous one as follows:
tarun@chawla~$java -version

tarun@chawla~$java version "1.6.0_23"
Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
Java HotSpot(TM) Server VM (build 19.0-b09, mixed mode)
If this comes as output then enjoy programming buddy.

And now save the .bashrc file.One thing can be considered here that you can put jdk1.6_23 folder any where at some other place and modify the path accordingly.

No comments:

Post a Comment