Can any one tell me, how to set java home in Ubuntu 12.10?
-
1Possible duplicate of How to set JAVA_HOME for OpenJDK? – kiri Oct 09 '15 at 11:43
5 Answers
Open terminal by hitting Ctrl+Alt+T and execute following command:
gedit ~/.bashrc
Now go to end of file and add the following lines:
export JAVA_HOME=/path/to/jdk/folder
#usually /usr/java/jdk or /usr/lib/java/jdk
export PATH=$PATH:$JAVA_HOME/bin
Now in terminal type:
sudo source ~/.bashrc
This will make it appear on every terminal if open.
Now you can cross check it by typing following line in terminal
echo $PATH
It will show you path of your jdk at the end
For more information visit this link

- 28,246
- 16
- 81
- 118

- 436
-
2You don't need to use sudo to edit your own .bashrc, but it still works, so +1 – Aaron Apr 04 '13 at 13:21
Try This:
JAVA_HOME=/usr/lib/jvm/java
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH
This should work, but make sure to change /usr/lib/jvm/java
with your java path.

- 554
Well that will be easy, just open terminal and do
For one user
gedit ~/.bash_profile
For all users
gedit /etc/profile
And just add line like this
export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
Just make sure that path is right. And if you did it for all users you will need to activate it using
sudo source /etc/profile
Source: http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/

- 6,596
To set JAVA_HOME for all users do as Follows:
sudo gedit /etc/environment
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 )

- 388
I installed Java 11 in Ubuntu 20.04 by setting JAVA_HOME
for the same...
Check your Ubuntu version:
$ lsb_release -d
Description: Ubuntu 20.04.3 LTS
find out the location of your jvm:
$ whereis jvm
jvm: /usr/lib/jvm
open .bashrc
in any editor of your choice:
$ nano ~/.bashrc
add the following lines to it:
## setting JAVA_HOME
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH
now your JAVA_HOME
is set.
Open a terminal and enter the command to confirm the setup:
$ echo $JAVA_HOME
This will output the same path you've set just now.

- 7,440

- 101
- 2