简体   繁体   中英

How to make both javac and java on my path in ubuntu 16.04 LTS

I need to make both javac and java on my path. I used the commands I got from other sites

$ sudo apt-get install default-jre
$ sudo apt-get install default-jdk

$ java -version
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

$ which java
/usr/bin/java

$ sudo update-alternatives --config java
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
Nothing to configure.

Now provided all of these information, how can I set the path? I am comfortable using vi ~/.bashrc . So please guide me step by step for the setup. I found other posts very confusing.

sudo vim .bashrc

(Check this path "/usr/lib/jvm/java-8-oracle" if jvm installed their)

export JAVA_HOME=/usr/lib/jvm/java-8-oracle


export PATH=$PATH:$JAVA_HOME/bin

save it.

run

bash 

or

source .bashrc

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