LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-09-2019, 10:38 AM   #1
supermario18b
LQ Newbie
 
Registered: Sep 2018
Posts: 18

Rep: Reputation: Disabled
update-alternatives and default-java symbolic link (on Debian 10 Buster)


Hi everyone,

I noticed that when I use the command "update-alternatives" to change the default java version the "default-java" symbolic link in /usr/lib/jvm doesn't change. It still points to the old default java version. Why?

Everything works fine, if I type "java -version" on terminal it shows the desired java version. Only the symbolic link doesn't change.

Shouldn't it change?
 
Old 10-10-2019, 02:20 PM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
show us the full output of all commands that led to your conclusion.
 
Old 10-12-2019, 09:13 AM   #3
supermario18b
LQ Newbie
 
Registered: Sep 2018
Posts: 18

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ondoho View Post
show us the full output of all commands that led to your conclusion.
Hi, here is the output with java11 as default:

Code:
------------------------------------------------------------
  0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1111      
* 1            /opt/jdk11/bin/java                           3         
  2            /opt/jdk12/bin/java                           4         
  3            /opt/jdk8/bin/java                            1         
  4            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1111

the java -version is right:

Code:
root@debian:~# java -version
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
so it works and the default link is right:

Code:
root@debian:~# ls -l /usr/lib/jvm/
lrwxrwxrwx 1 root root   25 dec 30  2018 default-java -> java-1.11.0-openjdk-amd64
lrwxrwxrwx 1 root root   21 jun 16 20:24 java-1.11.0-openjdk-amd64 -> java-11-openjdk-amd64
drwxr-xr-x 7 root root 4096 aug  9 07:22 java-11-openjdk-amd64
Now I switch to java 8 with "update-alternatives --config java" and here is the output:

Code:
------------------------------------------------------------
  0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1111      
  1            /opt/jdk11/bin/java                           3         
  2            /opt/jdk12/bin/java                           4         
* 3            /opt/jdk8/bin/java                            1         
  4            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1111

The java version is right:

Code:
root@debian:~# java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_222-b10)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.222-b10, mixed mode)

So it works but the java default link still points to the version 11 of java:

Code:
root@debian:~# ls -l /usr/lib/jvm/
lrwxrwxrwx 1 root root   25 dec 30  2018 default-java -> java-1.11.0-openjdk-amd64
lrwxrwxrwx 1 root root   21 jun 16 20:24 java-1.11.0-openjdk-amd64 -> java-11-openjdk-amd64
drwxr-xr-x 7 root root 4096 aug  9 07:22 java-11-openjdk-amd64
 
Old 10-13-2019, 04:21 AM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
I think the other java versions should be listed in /usr/lib/jvm/ as well.
How did you install them? Seems strange, to /opt.
 
Old 10-13-2019, 07:25 AM   #5
supermario18b
LQ Newbie
 
Registered: Sep 2018
Posts: 18

Original Poster
Rep: Reputation: Disabled
I've manually installed (copied) the other java version in /opt. I just tried to install that in /usr/lib/jvm and I can switch between java versions but the symbolic link still only points to a java version.
 
Old 10-14-2019, 01:58 AM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by supermario18b View Post
I've manually installed (copied) the other java version in /opt. I just tried to install that in /usr/lib/jvm and I can switch between java versions but the symbolic link still only points to a java version.
So you completely circumvented APT package management to install various java versions.
Since update-alternatives is an APT thing, I'm not surprised it doesn't work.
 
Old 10-14-2019, 11:05 AM   #7
supermario18b
LQ Newbie
 
Registered: Sep 2018
Posts: 18

Original Poster
Rep: Reputation: Disabled
You mean that if I would have installed the various java versions with APT, the default-java link would have been changed too.
Is it important? I mean, I noticed that the symbolic link doesn't change but everything works fine (the switch works fine). Has this default-java link some other function/implication?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Debian Outs First Linux Kernel Security Update for Debian GNU/Linux 10 "Buster" LXer Syndicated Linux News 0 07-30-2019 01:03 AM
LXer: Debian 11 "Bullseye" and Debian 12 "Bookworm" Are Coming After Debian 10 "Buster" LXer Syndicated Linux News 0 04-18-2018 12:26 PM
Physical link vs Relative link vs Symbolic link hack3rcon Linux - Newbie 13 01-13-2018 10:48 AM
[SOLVED] update-alternatives: error: unable to read link `/etc/alternatives/editor': Invalid a ccc Debian 1 12-16-2013 01:51 AM
Symbolic link in /etc/alternatives not working as intended davidas Debian 2 04-10-2004 07:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration