How to set Java environment path in Ubuntu

Ullas Prabhakar picture Ullas Prabhakar · Mar 8, 2012 · Viewed 583.7k times · Source

I just installed JDK in Ubuntu with sudo apt-get install openjdk-6-jdk command, after the installation where's the Java bin directory located? And how can I set the environment path for that directory? I have little experience with Ubuntu, can anyone give some advice or suggest any good website for reference?

Answer

Pratap Singh picture Pratap Singh · Sep 24, 2013

set environment variables as follows

Edit the system Path file /etc/profile

sudo gedit /etc/profile

Add following lines in end

JAVA_HOME=/usr/lib/jvm/jdk1.7.0
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH

Then Log out and Log in ubuntu for setting up the paths...