Check jdk version linux

Как проверить версию Java

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Выводы

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

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

Источник

How to Check Java Version Installed on Linux

Home » SysAdmin » How to Check Java Version Installed on Linux

How do I check my current Java version? There are several ways to check if Java is installed and which version is running on your system.

In this tutorial, learn how to check the Java version installed on Linux distros, including Ubuntu, CentOS, and Debian.

  • A user account with sudo privileges
  • Access to the command-line/terminal window
  • A version of Java

Method 1: Check the Java Version On Linux

To check the Java version on Linux Ubuntu/Debian/CentOS:

1. Open a terminal window.

2. Run the following command:

3. The output should display the version of the Java package installed on your system. In the example below, OpenJDK version 11 is installed.

Note: If the output indicates there is no such package on the system, you can install it with the help of one of our guides – How to install Java on Ubuntu or How to Install Java on CentOS.

You can also check the version of the primary Java compiler – javac (pronounced “java-see”) with the command:

Method 2: Find Version by Checking Path Where Java is Installed

There are two ways to find the path of the Java directory.

The first option includes running a single command:

The system should respond with the path where Java is installed.

Note: This option may not work on CentOS systems. If you have issues finding the path of the Java directory with the command above, use the alternative outlined below.

Alternatively, you can use the whereis command and follow the symbolic links to find the Java path.

1. Run the command:

The output tells you that Java is located in /usr/bin/java.

2. List the content of the /usr/bin/java directory:

Inspecting the directory shows that /usr/bin/java is only a symbolic link for /etc/alternatives/java.

3. Just like in the previous step, list the content of the provided path by running:

Finally, the output displays /etc/alternatives/java is another symbolic link and that the real path of the Java directory is /usr/lib/jvm/java-11-openjdk-amd64/bin/java.

Method 3: Search for Java in the Installed Packages List

You can also prompt the system to list installed packages and search for Java, with its version number.

Find Java by listing all installed packages.

1. To generate a list of all installed packages, use the command:

2. Scroll up/down until you find the Java packages as shown in this example.

To avoid searching through all installed packages, list Java packages only. Prompt the system to list a specific software package. In this case, the package name is openjdk:

Читайте также:  Планировщик задач для mac os

Note: CentOS users need to modify the commands for listing installed packages for their package manager. Use the commands: sudo yum list installed and sudo yum list installed | grep -i openjdk instead.

With this article, you have successfully checked the Java version installed on Linux. We also covered checking the Java path and searching for Java among the installed packages.

Once the Java version is confirmed, you can start developing anything from lightweight mobile to desktop applications.

Источник

How to check JDK version that installed on your computer

By mkyong | Last updated: June 29, 2020

Viewed: 515,144 (+1,756 pv/w)

The Java development kit (JDK) contains tools for Java development, and the Java Runtime Environment (JRE) contains a JVM to convert byte code .class to machine code, and execute it, in short, the JRE runs Java program.

Check JDK Version
We can use javac -version to find out the version of the installed JDK. In the below example, the JDK version is 11.0.7

Check JRE Version
We can use java -version to find out the version of the installed JRE. In the below example, the JRE version is 1.8.0_252

The JDK and JRE versions can be different on the same computer. Multiple JDK and JRE versions are allowed on the same computer; it is better to find out which version is configured in the system classpath to run or compile the Java program.

1. Where JDK is installed?

The JDK also contains a JRE to run the Java program.

1.1 On Ubuntu or Linux, we can use which javac to find out where JDK is installed.

In the above example, the JDK is installed at /usr/lib/jvm/adoptopenjdk-11-hotspot-amd64/ .

1.2 On Windows, we can use where javac to find out where JDK is installed.

Do I need JDK or JRE?
For end-users, they need to install JRE to run the Java program, and the JDK is for developers. For the production environment, the deployment team only need to install JRE to run the Java program. However, developers often request to install the JDK, instead of the standalone JRE on the production server, because the JDK contains JRE and also extra tools to monitor and debug the running Java program.

Источник

Where can I find the Java SDK in Linux after installing it?

I installed JDK using apt-get install but I don’t know where my jdk folder is. I need to set the path for that. Does any one have a clue on the location?

14 Answers 14

This depends a bit from your package system . if the java command works, you can type readlink -f $(which java) to find the location of the java command. On the OpenSUSE system I’m on now it returns /usr/lib64/jvm/java-1.6.0-openjdk-1.6.0/jre/bin/java (but this is not a system which uses apt-get ).

On Ubuntu, it looks like it is in /usr/lib/jvm/java-6-openjdk/ for OpenJDK, and in some other subdirectory of /usr/lib/jvm/ for Suns JDK (and other implementations as well, I think).

For any given package you can determine what files it installs and where it installs them by querying dpkg. For example for the package ‘openjdk-6-jdk’: dpkg -L openjdk-6-jdk

will tell you which java implementation is the default for your system and where in the filesystem it is installed. Check the manual for more options.

should give you something like

This question will get moved but you can do the following

Use find to located it. It should be under /usr somewhere:

When running the command, if there are too many «Permission denied» message obfuscating the actual found results then, simply redirect stderr to /dev/null

Another best way to find Java folder path is to use alternatives command in Fedora Linux (I know its for Ubuntu but I hit this post from google just by its headline). Just want to share incase people like me looking for answers for fedora flavour.

To display all information regarding java

Three Step Process: First: open Terminal-> $ whereis java it would give output like this: java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz

Second: ls -l /usr/bin/java It would give output like this: lrwxrwxrwx 1 root root 22 Feb 9 10:59 /usr/bin/java -> /etc/alternatives/java

Third: ls -l /etc/alternatives/java output is the JDK path: lrwxrwxrwx 1 root root 46 Feb 9 10:59 /etc/alternatives/java -> /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

It’s /usr/local/java/jdk[version]

the command: sudo update-alternatives —config java will find the complete path of all installed Java versions

This question still seems relevant, and the answer seems to be a moving target.

On my debian system (buster):

However, if you actually go look there, you’ll see there are multiple directories and symbolic links placed there by the package system to simplify future maintenance.

The actual directory is java-11-openjdk-amd64 , with another symlink of default-java . There is also an openjdk-11 directory, but it appears to only contain a source.zip file.

Given this, for Debian ONLY, I would guess the best value to use is /usr/lib/jvm/default-java , as this should always be valid, even if you decide to install a totally different version of java, or even switch vendors.

The normal reason to want to know the path is because some application wants it, and you probably don’t want that app to break because you did an upgrade that changed version numbers.

Читайте также:  Торговый терминал для linux

Источник

6 JDK Installation for Linux Platforms

This page describes JDK for Linux system requirements and gives installation instructions for several JDK-Linux combinations.

This page contains these topics:

See «JDK 8 and JRE 8 Installation Start Here» for general information about installing JDK 8 and JRE 8.

For information on enhancements to JDK 8 that relate to the installer, see «Installer Enhancements in JDK 8».

System Requirements

See http://www.oracle.com/technetwork/java/javase/certconfig-2095354.html for information about supported platforms, operating systems, and browsers.

On a 64-bit system, you can download either the 64-bit or the 32-bit version of the Java platform. However, if you are using a 32-bit browser and you want to use the plugin, then you need to install the 32-bit version of the Java platform. To determine which version of Firefox you are running, launch the application, and select the menu item Help -> About Mozilla Firefox. At the bottom of the window is a version string line that contains either «Linux i686» (32-bit) or «Linux x86_64» (64-bit). To setup the Java plugin, see «Manual Installation and Registration of Java Plugin for Linux».

JDK 8 Installation Instructions

This topic describes:

Installation Instructions Notation and Files

For instructions containing the notation version , substitute the appropriate JDK update version number. For example, if you are installing update JDK 8 update release 2, the following string representing the name of the bundle:

Note that, as in the preceding example, the version number is sometimes preceded with the letter u , for example, 8u2 , and sometimes it is preceded with an underbar, for example, jdk1.8.0_02 .

The following table lists the options and instructions for downloading the JDK 8 release on a Linux platform.

Download File and Instructions Architecture (CPU Type) Who Can Install
For Linux x64 systems: jdk-8u version -linux-x64.tar.gz
«Installation of the 64-bit JDK on Linux Platforms»
Intel — 64-bit anyone
For Linux aarch64 (64-bit ARM) systems: jdk-8u version -linux-aarch64.tar.gz (version 8u271 and later)
«Installation of the 64-bit JDK on Linux Platforms
ARM — 64-bit anyone
For Linux x86 systems: jdk-8u version -linux-i586.tar.gz
«Installation of the 32-bit JDK on Linux Platforms»
Intel — 32-bit anyone
For Linux x64 systems: jdk-8u version -linux-x64.rpm
«Installation of the 64-bit JDK on RPM-based Linux Platforms»
Intel — 64-bit RPM-based Linux root
For Linux aarch64 (64-bit ARM) systems: jdk-8u version -linux-aarch64.rpm (version 8u271 and later)
«Installation of the 64-bit JDK on RPM-based Linux Platforms»
ARM — 64-bit RPM-based Linux root
For Linux x86 systems: jdk-8u version -linux-i586.rpm
«Installation of the 32-bit JDK on RPM-based Linux Platforms»
Intel — 32-bit RPM-based Linux root

Installation can be performed using either of the following:

Installation of JDK using archive files ( .tar.gz ) allows you to install a private version of the JDK for the current user into any location, without affecting other JDK installations. However, it may involve manual steps to get some of the features to work (for example, the -version: release option of the java command, which allows you to specify the release to be used to run the specified class, requires the correct path to the JDK release under /usr/jdk ).

Installation of JDK using RPM packages allows you to perform a system-wide installation of the JDK for all users, and requires root access.

When you download and install the Java Development Kit (JDK), the associated Java Runtime Environment (JRE) is also installed.

JDK 7u6 and later releases include JavaFX SDK (version 2.2 or later). The JavaFX SDK and Runtime are installed and integrated into the standard JDK directory structure.

Installation of the 64-bit JDK on Linux Platforms

This procedure installs the Java Development Kit (JDK) for 64-bit Linux, using an archive file ( .tar.gz ).

These instructions use the following files:

jdk-8uversion-linux-x64.tar.gz and jdk-8uversion-linux-aarch64.tar.gz (version 8u271 and later) for 64-bit ARM systems.

Download the required file.

Before the file can be downloaded, you must accept the license agreement. The archive file can be installed by anyone (not only root users), in any location that you can write to. However, only the root user can install the JDK into the system location.

Change directory to the location where you would like the JDK to be installed, then move the .tar.gz archive file to the current directory.

Unpack the archive file and install the JDK.

  • For x64 — % tar zxvf jdk-8uversion-linux-x64.tar.gz
  • For 64-bit ARM system — % tar zxvf jdk-8uversion-linux-aarch64.tar.gz

The Java Development Kit files are installed in a directory called jdk1.8.0_ version in the current directory.

Delete the .tar.gz file if you want to save disk space.

Installation of the 64-bit JDK on RPM-based Linux Platforms

This procedure installs the Java Development Kit (JDK) for 64-bit RPM-based Linux platforms, such as Oracle, Red Hat and SuSE, using an RPM binary file ( .rpm ) in the system location. You must be root to perform this installation.

These instructions use the following files:

jdk-8uversion-linux-x64.rpm and jdk-8uversion-linux-aarch64.rpm (version 8u271 and later) for 64-bit ARM systems.

Download the required file.

Before the file can be downloaded, you must accept the license agreement.

Become root by running su and entering the super-user password.

Uninstall any earlier installations of the JDK packages.

Install the package:

  • For x64 — # rpm -ivh jdk-8uversion-linux-x64.rpm
  • For 64-bit ARM system — # rpm -ivh jdk-8uversion-linux-aarch64.rpm

To upgrade a package:

  • For x64 — # rpm -Uvh jdk-8uversion-linux-x64.rpm
  • For 64-bit ARM system — # rpm -Uvh jdk-8uversion-linux-aarch64.rpm

Delete the .rpm file if you want to save disk space.

Exit the root shell. No need to reboot.

Starting with version 8u40, the JDK installation is integrated with the alternatives framework and after installation, the alternatives framework is updated to reflect the binaries from the recently installed JDK. Java commands such as java , javac , javadoc , and javap can be invoked from the command line.

Using the java -version command, users can confirm the default (recently installed) JDK version.

In addition, users can now check which specific RPM package provides the java files:

Change in Communication With the Alternatives Framework of JDK RPM Installer Starting With JDK 8u261

Prior to JDK 8u261, the JDK RPM installers registered two groups of symbolic links with the alternatives framework, java and javac . In some versions of the alternatives framework, certain link names in these groups were duplicated, which resulted in installation failures.

Starting with JDK 8u261, the JDK RPM doesn’t register the javac group with the alternatives framework. All links unique to the javac group are moved into the java group, but the set of symbolic links registered by the installer are not changed; only the duplicated links have been dropped.

The implication of this change is that if you install JDK 8u261 and JDK 8u251 (or older versions) and uninstall JDK 8u261, the symbolic links from the java group that are managed by the alternatives framework will be deleted. To restore the deleted links, run the following command:

Installation of the 32-bit JDK on Linux Platforms

This procedure installs the Java Development Kit (JDK) for 32-bit Linux, using an archive file ( .tar.gz ).

These instructions use the following file:

Download the file.

Before the file can be downloaded, you must accept the license agreement. The archive file can be installed by anyone (not only root users), in any location that you can write to. However, only the root user can install the JDK into the system location.

Change directory to the location where you would like the JDK to be installed, then move the .tar.gz archive file to the current directory.

Unpack the archive file and install the JDK.

The Java Development Kit files are installed in a directory called jdk1.8.0_ version in the current directory.

Delete the .tar.gz file if you want to save disk space.

Installation of the 32-bit JDK on RPM-based Linux Platforms

This procedure installs the Java Development Kit (JDK) for 32-bit RPM-based Linux platforms, such as Red Hat and SuSE, using an RPM binary file ( .rpm ) in the system location. You must be root to perform this installation.

These instructions use the following file:

Download the file.

Before the file can be downloaded, you must accept the license agreement.

Become root by running su and entering the super-user password.

Uninstall any earlier installations of the JDK packages.

Install the package.

To upgrade a package:

Exit the root shell. No need to reboot.

Delete the .rpm file if you want to save disk space.

Starting with version 8u40, the JDK installation is integrated with the alternatives framework and after installation, the alternatives framework is updated to reflect the binaries from the recently installed JDK. Java commands such as java , javac , javadoc , and javap can be invoked from the command line.

Using the java -version command, users can confirm the default (recently installed) JDK version.

In addition, users can now check which specific RPM package provides the java files:

Installation of Public Key on RPM-based Linux Platforms

Since JDK version 8, the JDK RPMs are signed with OL keys. Installation of these RPMs on Linux distributions other than OL gives a warning message indicating that security validation of the package fails. This indicates that the public key used to sign this RPM needs to be installed in the system. A sample warning message and the public key installation steps are as follows:

Sample Warning Message
Installation Steps

Download the key file from https://yum.oracle.com/RPM-GPG-KEY-oracle-ol7 using the following command:

Install the key using the following command:

sudo rpm —import RPM-GPG-KEY-oracle-ol7

Public key installation needs to be done only once. The key installation is persistent across reboots.

General Installation Notes

This topic describes general installation topics.

Root Access

Installing the software automatically creates a directory called jdk1.8.0_ version . Note that if you choose to install the JDK into system-wide location, such as /usr/jdk , you must first become root to gain the necessary permissions. If you do not have root access, simply install the JDK into your home directory, or a subdirectory that you have permission to write to.

Overwriting Files

If you install the software in a directory that contains a subdirectory named jdk1.8.0_ version , the new software overwrites files of the same name in that jdk1.8.0_ version directory. Please be careful to rename the old directory if it contains files you would like to keep.

System Preferences

By default, the installation script configures the system such that the backing store for system preferences is created inside the JDK’s installation directory. If the JDK is installed on a network-mounted drive, it and the system preferences can be exported for sharing with Java runtime environments on other machines.

Источник

Читайте также:  Windows 10 elara что это такое
Оцените статью