Какая версия java установлена linux

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:

Читайте также:  Finding file path in linux

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

Java — один из самых популярных языков программирования в мире, используемый для создания различных типов кроссплатформенных приложений.

В этой статье объясняется, как с помощью командной строки проверить, какая версия Java установлена в вашей системе Linux. Это может быть полезно при установке приложений, требующих определенной версии Java.

Управление версиями Java

Java использует семантическое управление версиями . Версии готовых к выпуску релизов представлены по следующей схеме:

Например, в Java 11.0.8 11 — это основная версия, 0 — дополнительная версия, а 8 — версия безопасности.

  • MAJOR — Основные выпуски содержат новые возможности и функции.
  • MINOR — второстепенные выпуски содержат различные исправления ошибок и совместимые улучшения.
  • SECURITY — выпуски безопасности содержат критические исправления безопасности.

Проверка версии Java

Чтобы узнать, какая версия Java установлена в вашей системе, выполните команду java -version :

Команда отобразит версию Java по умолчанию:

openjdk 11.0.8 2020-07-14 OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu120.04) OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu120.04, mixed mode, sharing) 

В этом примере в нашей системе установлена Java версии 11.0.8 . Версия, установленная в вашей системе, может отличаться.

Если вы получили сообщение «java: command not found», это означает, что Java не установлена в системе. Чтобы установить Java, воспользуйтесь одним из следующих руководств в зависимости от вашего дистрибутива Linux:

В системе также может быть установлено несколько версий Java одновременно. Чтобы проверить, есть ли на вашем компьютере несколько установок Java:

sudo update-alternatives --config java

Если у вас только одна установка Java, результат будет выглядеть примерно так:

There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-11-openjdk-amd64/bin/java Nothing to configure. 

В противном случае, если у вас несколько установок Java, команда отобразит меню, в котором вы можете выбрать, какая версия будет версией Java по умолчанию:

There are 3 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 auto mode 1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode 2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode Press to keep the current choice[*], or type selection number: 

Чтобы изменить версию Java по умолчанию, просто введите номер версии (число в столбце «Выбор») и нажмите Enter .

Выводы

Узнать, какая версия Java установлена в вашей системе Linux, очень просто, просто введите java -version .

Читайте также:  Linux ping через определенный интерфейс

Не стесняйтесь оставлять комментарии, если у вас есть вопросы.

Источник

How can I tell what version of Java I have installed?

I want to start toying around with java (eventually getting to the point where I can write basic little programs for android or web), but I’ve managed to have java messed up on my computer (from past experiments). I’m not sure which version of java I have, and would like to know if there is a command to see the version of java that is installed and active. Also, which version works best? All this on 32bit Ubuntu 12.04 EDIT:
Ok, so it seems like I have both openjdk 6 and 7, with openjdk 7 in use. I want to use openjdk 7, so how do I uninstall openjdk 6? Is just via USC good enough or is there a command that should be run?

4 Answers 4

update-java-alternatives -l shows you all the Java versions you have installed.

java -version shows you the Java version you are using.

java -showversion shows you the Java version you are using and help.

Normally it would be OpenJDK.

This command should tell you what is currently providing the Java virtual machine ( java ) and the Java compiler ( javac ):

file /etc/alternatives/java /etc/alternatives/javac 

This assumes the «alternatives» system is working properly, which might not be the case, depending on how Java has been «messed up» in the past. To check this, run:

If the alternatives system is working correctly and being used by Java, then you should see:

/usr/bin/java: symbolic link to `/etc/alternatives/java' /usr/bin/javac: symbolic link to `/etc/alternatives/javac' 

Otherwise please edit your question to provide details. Then it should be possible to give a more specific answer.

You can remove openjdk-6 with the Software Center. There are multiple packages associated with it, so you may need to remove more than one packages. (All the `openjdk-6 packages are listed here.)

Or you can use the command-line:

sudo apt-get remove openjdk-6-\* icedtea-6-\* 

However, whichever method you use, you may want to check first to see what depends on these packages—you might have software installed that specifically needs version 6. (Probably not, but possibly.)

Читайте также:  Orange pi zero kali linux

You can check for this by simulating the removal operation on the command-line:

apt-get -s remove openjdk-6-\* icedtea-6-\* 

This will show you the effects of removing those packages, including what other packages would be removed as well. (You’ll notice that since this is a simulation, you don’t need sudo .)

If you want to be able to continue using Java content online in your web browser (this is not the same thing as JavaScript), then before you remove any icedtea-6- or openjdk-6- packages (except perhaps openjdk-6-jdk ), you should make sure you have icedtea-7- packages installed corresponding to whatever icedtea-6- packages are installed.

Источник

How to check java version at linux (RedHat6)

enter image description here

I am trying to check what java version I have installed in my linux machine, I have tried:

the console is returning nothing and getting stuck in a «java mode» , feels like the command called java and its waiting for my inputs, any thing I type then returns nothing. until I type crt+C it exits the mode.

3 Answers 3

If your java version more than 1.6 then it should work

if version is not installed it returns error message

Please share some snapshot so i can rectify it

To answer your question directly, you can use

For future Referenecs . You can try any of these commands.

rpm -qi «package_name_without_quotes»

It gives information of installed package. To display information about one or more packages (glob expressions are valid here as well), use the following command :

yum info «package_name_without quotes»

yum list «package_name_without_quotes»

yum —showduplicates list «package_name_without_quotes»

The yum info package_name command is similar to the rpm -q —info package_name command, but provides as additional information the ID of the Yum repository the RPM package is found in.

You can also query the Yum database for alternative and useful information about a package by using the following command :

yumdb info «package_name_without_quotes»

This command provides additional information about a package, including the check sum of the package (and algorithm used to produce it, such as SHA-256), the command given on the command line that was invoked to install the package (if any), and the reason that the package is installed on the system.

Источник

Оцените статью
Adblock
detector