简体   繁体   中英

Java Installation and Environment variable in Ubuntu

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.

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 
  • 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM