-2

I installed java 1.7 accord to this tutorial Install Oracle Java 7 in Ubuntu via PPA Repository.

All looks cool, when I run java -version I see:

java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)

But I need to set JAVA_HOME. Where is exactly java home on ubuntu?

Here is content of whereis and which for java:

nazar_art@nazar-desktop:~$ whereis java
java: /usr/bin/java /usr/bin/X11/java /usr/share/java /usr/share/man/man1/java.1.gz
nazar_art@nazar-desktop:~$ which java
/usr/bin/java
  • *How to set JAVA_HOME on Ubuntu?*
catch23
  • 17,519
  • 42
  • 144
  • 217

3 Answers3

1

JDK PPA has been deprecated long time ago due to licensing issues, I don't recommend using it.

Refer to this https://askubuntu.com/a/313182/70270 for installing/configuring Oracle JDK (manual or automated - using oab-java6).

NOTE: oab-java6 download the binary files from OTN and build .deb packages from them. Set up a local APT repository for easier maintenance.

I personally prefer to use a shell script and source it in the shell initialization files (for Ubuntu, use ~/.bashrc or ~/.profile)

For example, set_java.sh

JAVA_HOME=/opt/jdk1.7.0_40
CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
PATH=$JAVA_HOME/bin:$PATH
export PATH JAVA_HOME CLASSPATH
Community
  • 1
  • 1
Terry Wang
  • 13,840
  • 3
  • 50
  • 43
0
export JAVA_HOME=/path/to/somedir/jdk1.7.0_40
0

You need to use alternatives to figure out what /usr/bin/java

alternatives --display java

And this will reply

Current `best' version is /usr/java/jdk1.6.0_26/jre/bin/java.
David Brossard
  • 13,584
  • 6
  • 55
  • 88
  • `No command 'alternatives' found, did you mean: Command 'galternatives' from package 'galternatives' (universe) alternatives: command not found` – catch23 Oct 01 '13 at 17:02