I have recently installed ubuntu and want to start compiling programs in the terminal. What is the command to set the path for java in ubuntu terminal? I tried "cd path" but it did not work. Could anyone please tell me the right command?
first of all if you have not installed java you need to execute the command
$ sudo apt-get install openjdk-7-jdk
if it does not work then first execute
$ sudo apt-get update
and the execute the above command
and the do
$ sudo vi /etc/profile
and at the last line of the file add JAVA_HOME={path to java home} PATH=$JAVA_HOME/bin:$PATH
and do $ . /etc/profile
and now you are good to go to see the effect type java -version
Actually, you can avoid set the path by following phase:
First you can add ppa:
$ sudo add-apt-repository ppa:webupd8team/java
Then update:
$ sudo apt-get update
Then install it:
$ sudo apt-get install oracle-java8-installer
Finally, check it using the following command:
$ java -version
Result:
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) Server VM (build 25.5-b02, mixed mode)
Try export command.
Check in which location jdk is installed ( in ubuntu, its mostly in /usr/java/(javaVersion))
update the path variable using export:
export PATH=$PATH:/usr/java/(javaVersion)/bin
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.