Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can any one tell me, how to set java home in Ubuntu 12.10?

share|improve this question
Possible duplicate of How to set JAVA_HOME for OpenJDK? – minerz029 Oct 9 '15 at 11:43

Open terminal by hitting Ctrl+Alt+T and execute following command:

gedit ~/.bashrc

Now go to end of file and add the following lines:

export JAVA_HOME=/path/to/jdk/folder
#usually /usr/java/jdk or /usr/lib/java/jdk
export PATH=$PATH:$JAVA_HOME/bin

Now in terminal type:

sudo source ~/.bashrc

This will make it appear on every terminal if open.

Now you can cross check it by typing following line in terminal

echo $PATH

It will show you path of your jdk at the end

For more information visit this link

share|improve this answer
You don't need to use sudo to edit your own .bashrc, but it still works, so +1 – Aaron Apr 4 '13 at 13:21

Try This:

export JAVA_HOME
export PATH

This should work, but make sure to change /usr/lib/jvm/java with your java path.

share|improve this answer

Well that will be easy, just open terminal and do

  • For one user

    gedit ~/.bash_profile
  • For all users

    gedit /etc/profile

And just add line like this

export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
export PATH=$PATH:/usr/java/jdk1.5.0_07/bin

Just make sure that path is right. And if you did it for all users you will need to activate it using

sudo source /etc/profile


share|improve this answer

To set JAVA_HOME for all users do as Follows:

sudo gedit /etc/environment
JAVA_HOME =":usr/lib/jvm/java-7-openjdk-amd64/bin" 
CLASSPATH =":usr/lib/jvm/java-7-openjdk-amd64/bin:/home/something etc whatever you want etc"( separated by semicolon )
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.