- What is command to see all java versions installed on linux?
- 5 Answers 5
- Что такое команда, чтобы увидеть все версии Java, установленные на Linux?
- 5 ответов 5
- Finding installed Java versions actually being used on Linux servers?
- Finding installed Java versions actually being used on Linux servers?
- Linux version check Linux command or a Java code
- How to check all java version in linux
- Check if a program is installed on a linux machine from a java applet
- Find all Java versions in the system path
- 1 Answer 1
What is command to see all java versions installed on linux?
I know about java -version. I don’t care what version I’m currently running. I care what other versions are installed on my linux box. If it’s another java -* command I didn’t see it in the java -help. I’ve tried googling it but the answers are either for Windows or they say «use java -version.» I know I’ve done this before.
5 Answers 5
On most Linux distributions you can use update-alternatives like this:
sudo update-alternatives --config java
It will list all packages that provide java command and will let you change it. If you don’t want to change it, simply Ctrl-C from it.
There is only one catch — if you installed some java not using official package manager ( dpkg / apt-get , rpm / yum ), but simply extracted it, update-alternatives will not show it.
@Xiao: unfortunately, not all versions of update-alternatives have —list option. e.g. Centos 6.7 doesn’t.
To find all files. The package manager with your version of Linux should also be able to list them.
«package manager» . Unless someone installed a java version manually. Find is a valid approach, though 🙂 find / -type f -name java -print 2>/dev/null | xargs -i echo <> -version | bash
@tink How would one use the find with xargs but add a blank line between each version result when there are multiple ‘java’ executables?
@LeeMeador find /usr -type f -name java -print 2>/dev/null | xargs -i echo <> -version | bash 2>&1 | sed ‘:a;N;$!ba;s/\n/\n\n/g’
I use this to list the Java installs available:
sudo update-alternatives --display java
I was previously using the following to determine the java 8 installation for an application that needed an environment variable set so it could use a java version that was not set as the default:
update-java-alternatives -l java-8-oracle
However, that stopped working today. The update-java-alternatives script/program is no longer installed on my Ubuntu 14.04 system. What’s installed now is alternatives .
What I use now to get a specific alternatives java path is:
alternatives —display java | grep priority | grep jdk-1.8
Then I can massage the result to get what I need for my app’s environment variable.
Что такое команда, чтобы увидеть все версии Java, установленные на Linux?
Я знаю о Java-версии. Мне все равно, какую версию я сейчас использую. Меня волнует, какие другие версии установлены на моей Linux-коробке. Если это другая команда java — *, я не видел ее в java -help.
Я пытался найти его в Google, но ответы либо для Windows, либо они говорят «использовать Java-версию». Я знаю, что делал это раньше.
5 ответов 5
В большинстве дистрибутивов Linux вы можете использовать update-alternatives подобные этой:
sudo update-alternatives --config java
Он перечислит все пакеты, которые предоставляют команду java, и позволит вам ее изменить. Если вы не хотите его менять, просто Ctrl-C .
Есть только один улов — если вы установили java не используя официальный менеджер пакетов ( dpkg / apt-get , rpm / yum ), а просто распаковали его, альтернативы обновления не покажут его.
Чтобы найти все файлы. Менеджер пакетов с вашей версией Linux также должен иметь возможность перечислять их.
Вы оставляете желать лучшего, насколько подробно о вашей настройке идет. Java может быть установлена по-разному в Linux. Вы можете установить его с помощью пакета рассылки, например, apt, yum, yast, или установить его вручную.
Как бы вы ни устанавливали его, для установки Java в большинстве случаев нужен исполняемый файл Java, поэтому вы можете использовать команды locate или find для нахождения различных.
Пример, который, скорее всего, найдет ссылки и дубликаты, но имена каталогов должны помочь вам точно определить его:
for f in $(locate -ber '^java$'); do test -x && echo "$f"; done
Ранее я использовал следующее для определения установки java 8 для приложения, которому требовался набор переменных среды, чтобы он мог использовать версию java, которая не была установлена по умолчанию:
update-java-alternatives -l java-8-oracle
Однако сегодня это перестало работать. Сценарий / программа update-java-alternatives больше не устанавливается в моей системе Ubuntu 14.04. То, что установлено сейчас, это alternatives .
То, что я использую сейчас, чтобы получить конкретные альтернативные пути Java:
alternatives —display java | grep priority | grep jdk-1.8
Затем я могу помассировать результат, чтобы получить то, что мне нужно для переменной окружения моего приложения.
Finding installed Java versions actually being used on Linux servers?
Solution 1: The brute force solution (will include downtime and a lot of work): Prepare a documentation of all installed services, either create it or get it at hand Remove or disable all versions of Java Start one service after another Record all errors happening Fill in the necessary Java version for each service in the documentation (probably you can find out by the logs which Java version is necessary for what service) Reinstall or enable one version of Java at a time — probably best the one for the service you just were trying to bring up again Repeat for all services / java versions. Question: Our Linux servers (1500 of them) has multiple Java versions installed (from Java 1.5 to Java 17) and we are in process of cleaning it up.
Finding installed Java versions actually being used on Linux servers?
Our Linux servers (1500 of them) has multiple Java versions installed (from Java 1.5 to Java 17) and we are in process of cleaning it up. is there a way to find out which installed versions are actually being used?
we can take a snapshot of a process running at any point but this will miss the process which comes for a second and goes down.
Anyway to automate capturing this data, we have options to run ansible playbooks etc.
Any suggestions will be highly appreciated.
The brute force solution (will include downtime and a lot of work):
- Prepare a documentation of all installed services, either create it or get it at hand
- Remove or disable all versions of Java
- Start one service after another
- Record all errors happening
- Fill in the necessary Java version for each service in the documentation (probably you can find out by the logs which Java version is necessary for what service)
- Reinstall or enable one version of Java at a time — probably best the one for the service you just were trying to bring up again
Repeat for all services / java versions.
And for the future: keep records of the services that are running on your server and which dependencies they have.
Here is a bash script that might work for you:
#!/bin/bash while true do ps -aux | grep java | awk '' | xargs -I<> lsof -p <> | grep ' txt ' | awk '' >> log sort -u log > sorter cat sorter > log sleep .2 done
Every 200 milliseconds, it feeds the process id of every currently running process with «java» in it as the argument to the list-open-files utility, filters that list to include only executable files ( «txt» ), and appends that to a file called log. Then it writes the unique strings from that file to a file called sorter and then writes that back to the log file.
I executed a simple java Console app a few times with two different jvms while the script ran, and here’s the contents of the log file:
/usr/lib/jvm/java-11-openjdk-amd64/bin/java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
Running a ansible playbook and capturing the output to a excel sheet would be a good starting point.
Check if a program is installed on a linux machine from, Use the. which file. command to find out if the software is installed in the path. If that comes up with nothing then you could do a. find ./ -name «file». Also check their local bin or .bin if its not included …
Linux version check Linux command or a Java code
I want to check whether the currently installed RHEL version is greater that RHEL 6.
All I find is lots Linux commands to get the RHEL version. Some check files from /etc folder, some do RPM checks.
So I am bit confuse now and want something Rigid which will work even if version of OS changes later.
Please suggest me a way. Either linux command or a Java code. Anything will do.
cat /etc/*-release cat /etc/redhat-release
Looking at Java documentation I see you can get few basic information about the operating system via System.getProperty(), I suppose you use Java Standard Edition 6.0. But very likely also other versions should return same infos.
$ cat /etc/redhat-release Red Hat Enterprise Linux ES release 4 (Nahant Update 5)
$ uname -a Linux islamabad.bdnacn.com 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007 i686 i686 i386 GNU/Linux
Both of them will change if OS gets upgrade.
Bash Command to Check if Oracle or OpenJDK is, As we’ve known, the command “ java -version ” will print the detailed Java version information. So, for example, if we run it on a machine with Oracle JDK installed: $ java -version java version «15.0.2» 2021-01-19 Java (TM) SE Runtime Environment (build 15.0.2+7-27) Java HotSpot (TM) 64-Bit Server VM (build …
How to check all java version in linux
sudo update-alternatives --config java
Check if a program is installed on a linux machine from a java applet
Hi I need to be able to check if a certain software is installed on the clients computer and where, in order to launch it. I found the following three posts as to how to do so on Windows and Mac but I can’t seem to figure it out for Linux as there is no registry. Does any one know how this can be done on Linux?
Similar posts for Windows and Mac:
Can a Java applet open a «select directory» and write to a filesystem via JavaScript interaction?
read/write to Windows Registry using Java
How can I see the software installed in a Mac OS using a java application?
any help would be greatly appreciated 🙂
Assuming your security context allows it, you could call out to which .
which will output nothing if the program is not found.
command to find out if the software is installed in the path. If that comes up with nothing then you could do a
Also check their local bin or .bin if its not included in the path.
Well, basically every binary installed on Linux is in the PATH (environment variable), so if you can find it there, it’s there.
There may also be software that installs into other paths, but in this case the user would need to point them out. It is a very uncommon case to have an application in a seperate path and not adding that one to PATH.
Check installed java version linux Code Example, Follow. GREPPER; SEARCH SNIPPETS; FAQ; USAGE DOCS ; INSTALL GREPPER; Log In; All Languages >> Java >> Spring >> check installed java version linux >> Java >> Spring >> check installed java version linux
Find all Java versions in the system path
I needed to know a command to find all of the versions of Java in the system path. I knew that which -a java would print all places that the java executable can be found in the system path, but I then wanted to get the version info for each of these executables.
1 Answer 1
which -a java | xargs -I<> echo «echo <>;<> -version;echo» | sh
This will print the path to each of the java executables found in the system path, as well as the version information of that executable, and separate entries with a newline. It works like so:
- Pipe the output from which -a java into xargs
- Use xargs -I<> echo to construct bash commands, with each line in the input from which replacing <>
- Pipe the constructed bash commands into the system’s default shell executor.
A sample output on my machine gives
/usr/bin/java java version "1.8.0_131" Java(TM) SE Runtime Environment (build 1.8.0_131-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode) /usr/lib/jvm/java-8-oracle/bin/java java version "1.8.0_131" Java(TM) SE Runtime Environment (build 1.8.0_131-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
Note that if you want to know the versions of a different executable, you can modify the bash command that gets constructed to appropriately print version info. E.G. if you want to know all the versions of python you can run
which -a python | xargs -I<> echo «echo <>;<> —version;echo» | sh