- Как проверить версию Java
- Управление версиями Java
- Проверка версии Java
- Выводы
- How can I tell what version of Java I have installed?
- 4 Answers 4
- How to check Java Version on Linux Ubuntu
- Understanding the Java Version
- Checking Your Java Version
- Installing Java Using the Browser
- Some Important Commands
- Remove Java Versions
- Should You Use JRE or JDK?
- When to Use JDK
- When to Use JRE
- Some Applications of Java
- Conclusion
- About the author
- Zeeman Memon
Как проверить версию 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 .
Не стесняйтесь оставлять комментарии, если у вас есть вопросы.
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.)
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 on Linux Ubuntu
Java is a high-level, Object-Oriented programming language developed in 1995 by Sun Microsystems. Over time, Java has grown to become one of the most prominent high-level languages. It is now popular among app developers, financial, scientific, and estate enterprises. It is independent of the platform, open-source, versatile, and easy to learn and use.
It is practically a Turing-complete language so anything can be done on it. Most of the things one can do in Python can also be done in Java. Jpython is a Python version that runs on Java in the JVM (Java Virtual Machine). In this guide, we will dive into the procedure of looking up the Java version on Ubuntu Linux and install it if it is not already available.
Understanding the Java Version
The Java version is an indicator of the release of Java software currently under use by your OS.
It is highly recommended that the version be updated for better performance, stability, sophisticated features, and the latest security patches. This can go a long way and help you in preventing many unwanted issues and staying up to date.
Many websites, packages, or libraries require you to update to the latest Java version. So, it is preferred to stay one step ahead and have the latest release downloaded on your system. For instance, the latest Java version enables you to view 3D images along with other exciting features.
So, without further ado, let’s delve into the procedure of Java version verification and installation.
Checking Your Java Version
Start by checking your Java version. To do this, simply type the following in the terminal window.
This will give us the Java version that’s currently in use.
However, as evident from the picture above, Java isn’t installed on our system. But the terminal gives us options to install packages. Copying these commands and running them should get you the version installed directly via the terminal. All these versions are “headless”, meaning they don’t require a graphical user interface.
However, to download the latest release (16.02), you can use the browser method. Now, let’s go through the step-by-step process of installation.
Installing Java Using the Browser
Follow the steps to download Java.
Go to Google and search “download java JDK” and open the first link from the search results.
JDK is the “Java Development Kit” used to develop programs that run on Java. Alternatively, you can click on the link here to go directly to the page.
Under the “Java SE downloads”, go to “Java SE 16” as that is the latest version. The next step is to download JDK.
Scroll through the packages till you find the “Linux x64 Debian Package”. Download the file next to it. Ubuntu uses Debian packages to install programs, so you’ll see that the file has a .deb extension.
Once you are done with the download, open the folder where the downloaded package is located. Right-click anywhere in the window and select “Open in Terminal”.
Type the following command in the terminal to start unpacking the downloaded package.
You can replace the highlighted part of the command with the name of the package corresponding to the Java version you downloaded.
Having done that, you can type in the following command to confirm that Java is installed on your system.
With that out of the way, set your package as the alternative. To do that, use the following command:
$ sudo update-alternatives – install / usr / bin / java java / usr / lib / jvm / jdk-16.0.2 / bin / java 1
Now, we can finally check and verify our version by typing the following:
To install the compiler, just use the same command as before, only this time replace “java” with “javac”.
$ sudo update-alternatives – install / usr / bin / javac javac / usr / lib / jvm / jdk-16.0.2 / bin / javac 1
To check the Javac version, type the following command:
Additionally, to set the java_home path, enter the following:
$ sudo update-a;ternatives —config java
$ sudo gedit / etc / environment
Once the text editor opens, paste the copied line and assign it to “JAVA_HOME” as demonstrated below.
Once this is done, clear the screen and type in the following commands to complete the process of Java home path configuration.
Some Important Commands
Given below are certain commands you can use to check your version alongside other important things.
(This command shows all the Java versions installed on your system.)
(Shows Java version you are using.)
(Shows version of Java you are currently using.)
(Shows the version of Java compiler.)
(To find the location of Java.)
Remove Java Versions
To remove Java from your system, you can type in the following command:
Press “Y” followed by “ENTER” and the package will be uninstalled.
Should You Use JRE or JDK?
To run Java programs, you’ll need JRE (Java runtime environment). It is compatible with Windows, Linux, Mac, Solaris, and many more.
JDK (Java Development Kit) is used to develop Java applications. It is usually where most programmers start from. It depends on what you want to do.
When to Use JDK
- You want to write Java programs. It comes with a compiler and Java application launcher.
- Has access to the main Java libraries for coding via Java application launcher which opens JRE.
When to Use JRE
- You have to use libraries and other files. It does not have compiler and error detection agents of its own.
- When you have to use utility packages like math or data related sets and instructions.
- To run applications running on Java.
Some Applications of Java
- Building Android applications.
- In developing web and cloud applications.
- Software tools like Eclipse and Netbeans.
- Chatbots.
- Games.
- Scientific and Enterprise applications
Conclusion
To stay up to date and get a hands-on experience of the latest packages and software, keeping our programs updated is a must. This check and balance can really help us a long way in keeping our system efficient, protected, and up to date.
About the author
Zeeman Memon
Hi there! I’m a Software Engineer who loves to write about tech. You can reach out to me on LinkedIn.