Openjdk not installing properly


8 posts
by ginger3456 » Sun Nov 04, 2012 4:59 am
Hello

I tried installing the sun embedded java thingy from oracles website. Then, after some googling the error I received I understood that Raspbian did not support this version of java. So i deleted the folder I installed it in (as per google instructions) and installed openjdk 7.

sudo apt-get install openjdk-7-jre

Now when i type "java" in the command line it says "java: command not found".
Do I have to manually configure the path? If so, how do i do this?

Thank you
Posts: 5
Joined: Sun Nov 04, 2012 4:50 am
by Sander » Sun Nov 04, 2012 9:37 pm
Did the "sudo apt-get install openjdk-7-jre" go well?

Did you search your harddisk for "java"?

Code: Select all
sudo find / -name java -print


or maybe better:

Code: Select all
sudo find / -name java -print | grep bin
User avatar
Posts: 174
Joined: Wed Aug 31, 2011 1:01 pm
by ginger3456 » Sun Nov 04, 2012 9:51 pm
Thank you!
The install seemed to go ok.
"sudo find / -name java -print | grep bin" returns:
/usr/lib/jvm/java-7-openjdk-armhf/jre/bin/java
/usr/lib/jvm/java-7-openjdk-armhf/bin/java
/usr/bin/java

The two upper ones seem to be java. When i run them they return the standard java return message.
"/usr/bin/java" returns:
"no such file or directory"

How do i make it so that simply typing "java" in the commandline does what it is supposed to?
Posts: 5
Joined: Sun Nov 04, 2012 4:50 am
by Sander » Sun Nov 04, 2012 9:54 pm
"no such file or directory" is not what my java returns ... I fear the file is not there.

So, can you do:

Code: Select all
ls -al /usr/bin/java

and post it here.
User avatar
Posts: 174
Joined: Wed Aug 31, 2011 1:01 pm
by ginger3456 » Mon Nov 05, 2012 1:47 am
Yep. That returned
"lrwxrwxrwx 1 root root 22 Oct 24 22:34 /usr/bin/java -> /etc/alternatives/java".
I'm guessing this means that /usr/bin/java is pointing to some other file?
Posts: 5
Joined: Sun Nov 04, 2012 4:50 am
by Sander » Mon Nov 05, 2012 6:32 am
This is how it is on my Ubuntu:

Code: Select all
sander@R540:~$ which java
/usr/bin/java

sander@R540:~$ ls -al /usr/bin/java
lrwxrwxrwx 1 root root 22 Jun 27 14:13 /usr/bin/java -> /etc/alternatives/java*

sander@R540:~$ file /etc/alternatives/java
/etc/alternatives/java: symbolic link to `/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java'

sander@R540:~$ file /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xada2c0013f198b26b97787b5bf76c60050b2de0f, stripped



So: /usr/bin/java eventually points to /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java, which is the executable.

Can you check the above commands on your Raspi?
User avatar
Posts: 174
Joined: Wed Aug 31, 2011 1:01 pm
by xranby » Mon Nov 05, 2012 9:04 am
Batchtuning:
The Debian/Raspbian tool that is designed to set the java symlink is:
update-java-alternatives

Try running update-java-alternatives -l to get a list of installed jre and jdk on your system:
update-java-alternatives -l


Then set the default that you want to use using:
sudo update-java-alternatives -s java-1.7.0-openjdk-armhf


update-java-alternatives will change all java launchers, java, javac .. and the webbrowser plugin in one go. I recommend changing all the java symbolic-links using the update-java-alternatives tool.

Finetuning:
It is possible to configure the alternative system to pick say java from openjdk-6 and javac from openjdk7 by using update-alternatives :
If you only want to correct the symlink to java then use
update-alternatives --list java
sudo update-alternatives --set java /usr/lib/jvm/java-7-openjdk-armhf/jre/bin/java
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby
User avatar
Posts: 401
Joined: Sat Mar 03, 2012 10:02 pm
by ginger3456 » Mon Nov 05, 2012 12:20 pm
Thank you all.
The last reply was right on the money.
Posts: 5
Joined: Sun Nov 04, 2012 4:50 am