Centos 7 how get alternatives list for java
12,704
It appears than the option --list doesn't take arguments, it's a bug in the manual synopsis.Moreover for manage my java versions I should try env variables.
(The bug has been reported as https://github.com/fedora-sysv/chkconfig/issues/11)
Related videos on Youtube
Author by
UnRealCloud
Updated on June 04, 2022Comments
-
UnRealCloud almost 2 years
I would like to get the list of all alternatives for java versions, choose one and set it in a script, but option --list doesn't not work as expected:
alternatives --list java alternatives version 1.7.4 - Copyright (C) 2001 Red Hat, Inc. This may be freely redistributed under the terms of the GNU Public License. usage: alternatives --install <link> <name> <path> <priority> [--initscript <service>] [--family <family>] [--slave <link> <name> <path>]* alternatives --remove <name> <path> alternatives --auto <name> alternatives --config <name> alternatives --display <name> alternatives --set <name> <path> alternatives --list common options: --verbose --test --help --usage --version --keep-missing --altdir <directory> --admindir <directory>
For the moment I create my own list with
/etc/alternatives
, but I'm not satisfied. How can I get a list like :# alternatives --config java There are 2 programs which provide 'java'. Selection Command ----------------------------------------------- + 1 java-1.7.0-openjdk.x86_64 (/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.191-2.6.15.4.el7_5.x86_64/jre/bin/java) * 2 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64/jre/bin/java)
-
Stephen C over 5 yearsUmm ... am I missing something? Can't you just get your script to run
alternatives --config java
if you want the user to choose, oralternative --set java <path>
? -
Stephen C over 5 yearsAnyhow, this shouldn't be tagged with
java
since it is entirely about wrangling thealternatives
command. -
UnRealCloud over 5 yearsI don't run run
alternatives --config java
, because it requires user input .You can usealternatives --set <name> <path>
-
Stephen C over 5 yearsCorrect. So what is your question?
-
UnRealCloud over 5 yearsI don't want an user to choose which version, I want launch a script who require a specific version of openjdk, so I want to know if an alternative exits for this version. I need to get what usually you get with the command
alternatives --list java
, but for some reasons doesn't work here . -
Stephen C over 5 yearsIf you want your script to use a specific version of Java, you don't use "alternatives". You simply add the path to the required version to the script's $PATH ... or use an absolute pathname. And there are various symlinks to help you do this.
-
Stephen C over 5 yearsSorry ... but alternatives is not smart enough to do this kind of thing. You are better off just using your knowledge of how the standard openjdk symlinks work for your OS platform.
-
UnRealCloud over 5 yearsOk, that's clearer, thank you; But do you have an idea why
alternatives --list
doesn't work? -
Stephen C over 5 yearsBecause it doesn't. The
--list
option is designed to list all link groups and what they are currently configured to. It don't take a<name>
argument. Like the--help
output and the manual entry both say. -
UnRealCloud over 5 yearsBut in the synopsis there is alternatives [options] --list name, this is what fooled me
-
Stephen C over 5 yearsTrue. That's a documentation bug.
-
UnRealCloud over 5 yearsOk, well thank you very much for your time given, I'hv learn a lot, it's a great day !
-