0

I'm trying to install Java in Ubuntu 14.04. I had follow a guide (that was sent to me for a work for my thesis) and this is what I made:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

Now I have to change the environment variable and, according to the guide, this is the few steps remaining:

  • sudo update-alternatives --config java for get the environmnet variable path
  • $JAVA_HOME: sudo nano /etc/environment
  • JAVA_HOME=/usr/lib/jvm/java-7-oracle
  • source /etc/environment

the problem is that I'm not sure where I have to write "JAVA_HOME: bla bla". In the Ubuntu shell? And, at the end, source /etc/environment doesn't work.

1
  • You should also set your PATH variable as well. Check the profile file of your shell Commented Nov 12, 2015 at 15:21

2 Answers 2

1

You can set the JAVA_HOME variable in your ~/.bashrc file, probably the end of the file is the best place:

vi ~/.bashrc         # open the file and add the value
source ~/.bashrc     # source it
echo $JFHOME         # make sure it changed

Then, you may need to add this path into $PATH:

PATH=$PATH:$JAVA_HOME 
Sign up to request clarification or add additional context in comments.

2 Comments

when you write "add the value" you means only JAVA_HOME=/usr/lib/jvm/java-7-oracle (obviously at the end of the file)?
@Carlo check if echo $JAVA_HOME returns what you inserted.
0
  • vim /etc/profile

  • modify file ,add the two lines

JAVA_HOME=/usr/lib/jvm/java-7-oracle

PATH=$JAVA_HOME/bin:$PATH

  • source /etc/profile

make sure all the above has been done then run "java -version" see if it works or not.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.