2

I installed the last image "RASPBIAN Debian Wheezy" on my Pi and it contains java 8 After that I installed java 7: and I want to modify the java path from java 8 to java 7 So I updated my environment variables to:

export JAVA_HOME=/usr/lib/jvm/jdk-7-oracle-armhf/bin/java
export PATH=$PATH:/usr/lib/jvm/jdk-7-oracle-armhf/bin

I added them to my ~/.bashrc

but still when I execute java -version I got the java 8, even after reboot:

java -version
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) Client VM (build 25.0-b70, mixed mode)

and when I display my envirnment variables, I got the java 7!:

echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/usr/lib/jvm/jdk-7-oracle-armhf/bin

pi@raspberrypi /usr/bin $ echo $JAVA_HOME
/usr/lib/jvm/jdk-7-oracle-armhf/bin/java

How can I update the path so that the command "java -version" gave me the java 7?

1
  • Have you tried to uninstall Java 8? Or you need it too? Commented Jun 16, 2015 at 14:25

2 Answers 2

4

You need to use update-alternatives

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk-7-oracle-armhf/bin/java" 1  
sudo update-alternatives --set java /usr/lib/jvm/jdk-7-oracle-armhf/bin/java

If still having problems check here http://www.element14.com/community/docs/DOC-54112/l/java-on-the-raspberry-pi

Sign up to request clarification or add additional context in comments.

Comments

0

Simply, your PATH is in the wrong order. The conventional way would be:

export JAVA_HOME=/usr/lib/jvm/jdk-7-oracle-armhf
export PATH=$JAVA_HOME/bin:$PATH

Note that I prepended your new java. Since PATH is searched in order, it would still find the old java first, otherwise.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.