Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

we are new to Ubuntu.Recently we changed my server OS to ubuntu 12.04 from windows 7 . every one have their own login details. one of my college installed Open-Jdk7. I asked him, where you installed JAVA, then he suggested to switch the following directory

su root
cd /usr/lib/Jvm

Totally 3 folders are there in JVM folder. names are.

  1. java-1.7.0-openjdk-amd64

  2. java-7-openjdk-amd64

  3. java-7-openjdk-common

generally, If you install Java in Windows, we will get 2 folder. 1 folder is for JDKand another points to JRE.

but, in Ubuntu we have 3 folders. is it right?

for my conformation, whether he installed correctly or not. I open Terminal. I run the following 2 commands

 java -version

both commands are working fine.

now I want to set-up Java-Home and Path for all users at same place.because everyone is working on Application server.

Can anyone explain step-by-step.


share|improve this question
The best way to setup environment variables for all users is editing /etc/environment file. It has pretty simple syntax. And to setup user-specific environment variable you should edit ~/.bashrc file. Add the export VAR=value to the end of this file. –  Danatela Jul 18 '13 at 7:55
I mention like this. PATH=PredefinePaths:/usr/lib/jvm/java-7-openjdk-amd64/bin JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64". I didn't mention any special charachers in between Path and JAVA-HOME variables. Is it right, What I did –  ur truly friend Jul 18 '13 at 11:07
I see you came from Windows world :) There is no need to change PATH variable. Just add JAVA_HOME and JDK_HOME if some application requires them. –  Danatela Jul 18 '13 at 11:16

3 Answers 3

Installation of Oracle Java:

  1. Donwload the tarball from Oracle website
  2. unzip it by sudo tar -xvpzf fileName -C /installation_folder_name
  3. change the files permission and ownership
  4. add the following two lines in /etc/profile

export JAVA_HOME=/home/abu/Java/jdk1.8.0_45/ export PATH=$JAVA_HOME/bin:$PATH

  1. restart the machine and check by java -version and javac -version
share|improve this answer
sudo gedit /etc/environment

then add these lines

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
JAVA_HOME should point to a java installation folder, not its bin subfolder. And what's with those colons? –  Marko Bonaci Oct 19 '13 at 22:25

Edit the system Path file /etc/profile

sudo -H gedit /etc/profile # always use -H when you sudo a gui program or anything else which might write config files to the $HOME directory.

Add following lines in end

export JAVA_HOME
export JRE_HOME
export PATH

For complete installation guide..

share|improve this answer
i tried this but still got the same error –  Nitesh Verma Dec 8 '14 at 8:35

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.