Reputation: 4179
EDIT
I am trying to install Hadoop 2.6.0 on my Ubuntu 14 machine. I am coming across an error though.
When I am trying to set the HOME
variable for Java it does not seem to be doing as expected.
I am on my machine as hduser
setup specifically for running and using Hadoop. This user is a sudoer.
Some information:
java -version' gives the following
java version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.5) (7u79-2.5.5-0ubuntu0.14.04.2)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)
This is the only version installed on my machine, which can be seen by running the following command:
update-alternatives --display java
Which gives the following message:
java - auto mode
link currently points to /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java - priority 1071
slave java.1.gz: /usr/lib/jvm/java-7-openjdk-amd64/jre/man/man1/java.1.gz
Current 'best' version is '/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java'.
I then go to the following path:
cd /usr/lib/jvm
and the I list out the contents ls
default-java java-1.7.0-openjdk-amd64 java-7-openjdk-amd64
I then type cd java*
and pwd
which brings up the following path:
/usr/lib/jvm/java-1.7.0-openjdk-amd64
Ok, so with that information, I then copy that directory into the .bashrc
file as follows:
# The java implementation to use.
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
The hadoop-env.sh
file I fill out as follows:
#Hadoop variables
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
I then at the terminal type source ~/.bashrc
and then restart the terminal in order for it to set to the new Java path. When typing Hadoop -version I get the following output:
/usr/bin/hadoop: line 350: /usr/lib/jvm/java-6-sun/bin/java: No such file or directory
/usr/bin/hadoop: line 434: /usr/lib/jvm/java-6-sun/bin/java: No such file or directory
I do not know where to go from here.
Thank you,
Upvotes: 1
Views: 2132
Reputation: 2574
Add JAVA_HOME
to point to your openjdk
in hadoop-env.sh
. Add this line in hadoop-env.sh
:
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
NOTE: Change JAVA_HOME path in .bashrc too
UPDATE I:
Run these commands in terminal. (This will set java & javac in /bin to use your jdk)
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-1.7.0-openjdk-amd64/bin/java 1
sudo update-alternatives --config java
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/java-1.7.0-openjdk-amd64/bin/javac" 1
sudo update-alternatives --config javac
NOTE: If you dont have java and javac in the specified path, it will be inside /jre folder. Change it respectively.
Upvotes: 2
Reputation: 2021
It seems that you have installed java (I mean JRE/JDK here) 1.6, 1.7 and 1.8 at the same time. Which is comlpetelly ok since java installations are usually managed via alternatives subsystem.
The problem is that (contrary to your expectations) setting JAVA_HOME
doesn't select which java is used. This is done via mentioned alternatives subsystem instead. The JAVA_HOME
variable itself is only addtional configuration and doesn't have power to override what is being executed when one asks to start java
process.
Moreover running cd java*
isn't really a good idea unless you would like to go into first directory which starts with given string. Try to run ls java*
to see my point. And again, it's ok to have multiple different versions of java here thanks to alternatives subsystem.
Another problem is that you are mixing different flavours of java which you probably don't have installed (java-8-oracle
vs java-6-sun
vs java-1.6.0-openjdk
.
To check which java is installed, run:
alternatives --display java
And then based on the results, swich to one version of java and set JAVA_HOME
accordingly.
Upvotes: 0