Which java installed linux

Содержание
  1. How to Check Java Version Installed on Linux
  2. Method 1: Check the Java Version On Linux
  3. Method 2: Find Version by Checking Path Where Java is Installed
  4. Method 3: Search for Java in the Installed Packages List
  5. Установка Java в Linux
  6. Чем отличается JDK от JRE
  7. Установка Java в Linux своими руками
  8. Установка Java в Ubuntu
  9. JRE и JDK
  10. Установка Java в ArchLinux
  11. Установка Java в CentOS
  12. Выбор версии Java
  13. Ubuntu
  14. ArchLinux
  15. CentOS
  16. Настройка переменных окружения
  17. Выводы
  18. Which java installed linux
  19. Contents
  20. Installation
  21. OpenJDK
  22. OpenJFX
  23. Other implementations
  24. Development tools
  25. Decompilers
  26. Switching between JVM
  27. List compatible Java environments installed
  28. Change default Java environment
  29. Unsetting the default Java environment
  30. Fixing the default Java environment
  31. Launching an application with the non-default java version
  32. Package pre-requisites to support archlinux-java
  33. Troubleshooting
  34. MySQL
  35. IntelliJ IDEA
  36. Impersonate another window manager
  37. Illegible fonts
  38. Missing text in some applications
  39. Gray window, applications not resizing with WM, menus immediately closing
  40. System freezes when debugging JavaFX Applications
  41. JavaFX’s MediaPlayer constructor throws an exception
  42. Java applications cannot open external links
  43. Error initializing QuantumRenderer: no suitable pipeline found
  44. Tips and tricks
  45. Better font rendering
  46. Silence ‘Picked up JDK_JAVA_OPTIONS’ message on command line
  47. GTK LookAndFeel
  48. GTK3 Support
  49. Better 2D performance

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:

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.

Источник

Установка Java в Linux

В этой статье речь пойдёт о проприетарной версии Java. Часто происходят ситуации, когда пользователь пытается открыть какую-либо программу на Java, а она либо вообще не запускается, либо пытается это сделать с помощью OpenJDK (Java Development Kit). Но вместо результата вы получаете кучу ошибок (как например с Minecraft). В данных ситуациях вам, скорее всего, поможет установка Java от Oracle.

Я вам расскажу, как установить JRE (Java Runtime Environment) и JDK (Java Development Kit) 8 версии на такие дистрибутивы, как Ubuntu, CentOS и Arch, а также как выбрать нужную среду по умолчанию.

Чем отличается JDK от JRE

  • JRE — Java Runtime Environment — это среда выполнения Java. Предназначена для обычного использования. Позволяет запускать приложения, написанные на языке Java.
  • JDK— Java Development Kit — стандартная версия платформы Java, предназначенная для разработки. Это специальный пакет разработчика, в который входят документация, различные утилиты, компилятор, библиотеки классов, а также сама JRE.

Установка Java в Linux своими руками

Скачать архив с необходимой вам версией вы можете с официального сайта. Далее вам надо перенести его в желаемую директорию и распаковать. Рекомендую /opt/java, далее она и будет использоваться. Сделайте это, используя следующие команды:

Читайте также:  Почему некорректно работает windows 10

sudo tar -xzf /opt/java/jre*.tar.gz

Где «*» — версия Java.

Загрузите архив со средствами разработчки с официального сайта компании Oracle. Также перенесите его в желаемую директорию и распакуйте:

sudo tar -xzf /opt/java/jdk*.tar.gz

Установка Java в Ubuntu

JRE и JDK

Для установки проприетарной Oracle Java вам необходимо добавить репозиторий, обновить индексы пакетов и установить Java. В Ubuntu, начиная с 18 релиза, это делается автоматически после добавления репозитория.

Внимание! Будут установлены как JRE, так и JDK. Сначала добавим репозиторий и обновим списки пакетов:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update

В процессе установки необходимо будет принять лицензионное соглашение:

sudo apt-get install oracle-java8-installer

Установка Java в ArchLinux

В официальных репозиториях есть только OpenJDK. Поэтому придётся воспользоваться пакетом из AUR(вы можете, конечно, руками установить Java от Oracle, но AUR проще). Установка производится всего одной командой:

JDK так же можно установить, используя AUR. Просто выполните команду:

Установка Java в CentOS

Для RHEL, Fedora, Cent OS, OpenSUSE есть официальный RPM-пакет, который вы можете скачать с официального сайта. Чтобы установить пакет из терминала, воспользуйтесь этой командой:

sudo rpm -i /путь/к/файлу/jre-*.rpm

где «*» — версия Java. Или же примените любую графическую утилиту.

Средства для разработчика вы можете скачать на сайте Oracle, ссылка на который есть в верху статьи. Для установки из терминала, используйте команду:

Где «*» — версия Java. «

» — указывает, что путь начинается.

Выбор версии Java

Ubuntu

Для переключения на 8 версию Java используйте следующую команду:

sudo update-java-alternatives -s java-8-oracle

Чтобы автоматически установить переменные среды, воспользуйтесь командой:

sudo apt-get install oracle-java8-set-default

Или же вы можете установить альтернативы сами. Делается это с помощью следующих команд:

sudo update-alternatives —install /usr/bin/java java / usr / lib / jvm / java-8-oracle/bin/java 1

sudo update-alternatives —install / usr / bin / javaс javaс / usr / lib / jvm / java-8-oracle / bin / javaс 1

sudo update-alternatives —install / usr / bin / javaws javaws / usr / lib / jvm /java-8-oracle / bin / javaws 1

Теперь осталось выбрать версии исполняемых файлов java, javaws и javac, которые будут использоваться по умолчанию:

sudo update-alternatives —config java

sudo update-alternatives —config javac

sudo update-alternatives —config javaws

ArchLinux

Для начала просмотрите список установленных сред:

Затем установите необходимую вам:

archlinux-java set имя_среды

archlinux-java set java-8-jre/jre

CentOS

Выбрать необходимую среду можно с помощью команд, данных ниже (так же, как и в Ubuntu). Вам нужно будет просто выбрать цифру, соответствующую номеру версии:

sudo update-alternatives —config java

sudo update-alternatives —config javac

sudo update-alternatives —config javaws

Настройка переменных окружения

Чтобы настройки были доступны для всех пользователей, будем использовать файл /etc/profile. Откройте его для редактирования любым текстовым редактором с помощью команды sudo и добавьте в конец следующие строки:

  1. export JAVA_HOME=/opt/java/jdk*/
  2. export JRE_HOME=/opt/java/jdk*/jre
  3. export PATH=$PATH:/opt/java/jdk*/bin:/opt/java/jdk*/jre/bin
  • Вместо пути по умолчанию /opt/java укажите тот, который использовали;
  • Если вы используете не JDK, а JRE, то в пути у вас так же будет не «jdk*», а «jre*»;
  • «*» — версия Java, которая у вас установлена.

Выводы

В данной статье мы подробно разобрали процесс установки и настройки Java в различных дистрибутивах Linux. Если остались вопросы, спрашивайте в комментариях!

Источник

Which java installed linux

Java is a programming language originally developed by Sun Microsystems and released in 1995 as a core component of Sun Microsystems’ Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture.

Arch Linux officially supports the open source OpenJDK versions 7, 8, 11 and 16. All these JVM can be installed without conflict and switched between using helper script archlinux-java . Several other Java environments are available in AUR but are not officially supported.

Contents

Installation

Two common packages are respectively pulled as dependency, named java-runtime-common (containing common files for Java Runtime Environments) and java-environment-common (containing common files for Java Development Kits). The provided environment file /etc/profile.d/jre.sh points to a linked location /usr/lib/jvm/default/bin , set by the archlinux-java helper script.

This is used to display and point to a working default Java environment in /usr/lib/jvm/java-$-$ or a Java runtime in /usr/lib/jvm/java-$-$/jre .

Most executables of the Java installation are provided by direct links in /usr/bin , while others are available in $PATH . The script /etc/profile.d/jdk.sh is no longer provided by any package.

OpenJDK

OpenJDK is an open-source implementation of the Java Platform, Standard Edition (Java SE), designated as the official reference implementation. There are several distributors of OpenJDK builds such as AdoptOpenJDK and Amazon Corretto. The Arch Linux OpenJDK packages are built from the upstream OpenJDK source code.

Headless JRE The minimal Java runtime — needed for executing non-GUI Java programs. Full JRE Full Java runtime environment — needed for executing Java GUI programs, depends on headless JRE. JDK Java Development Kit — needed for Java development, depends on full JRE.

Version Headless JRE Full JRE JDK Documentation Sources
OpenJDK 16 jre-openjdk-headless jre-openjdk jdk-openjdk openjdk-doc openjdk-src
OpenJDK 11 jre11-openjdk-headless jre11-openjdk jdk11-openjdk openjdk11-doc openjdk11-src
OpenJDK 8 jre8-openjdk-headless jre8-openjdk jdk8-openjdk openjdk8-doc openjdk8-src
OpenJDK 7 jre7-openjdk-headless jre7-openjdk jdk7-openjdk openjdk7-doc openjdk7-src

OpenJDK GA — Latest OpenJDK General-Availability Release build from Oracle.

OpenJDK EA — Latest OpenJDK Early-Access build for development version from Oracle.

IcedTea-Web — Java Web Start and the deprecated Java browser plugin.

OpenJFX

OpenJFX is the open-source implementation of JavaFX. You do not need to install this package if you are using Oracle JDK. This package only concerns users of the open source implementation of Java (OpenJDK project), and its derivatives.

Читайте также:  V uap41 драйвер windows 10
Version Runtime and Developement Documentation Sources
OpenJFX 16 java-openjfx java-openjfx-doc java-openjfx-src
OpenJFX 11 java11-openjfx java11-openjfx-doc java11-openjfx-src
OpenJFX 8 java8-openjfx java8-openjfx-doc java8-openjfx-src

OpenJFX GA — Latest OpenJFX General-Availability Release build from Gluon.

OpenJFX EA — Latest OpenJFX Early-Access build for development version from Gluon.

Other implementations

Oracle JDK — Oracle’s commercially licensed build of OpenJDK.

OpenJ9 — Eclipse’s implementation of JRE, contributed by IBM.

IBM Certified — IBM Semeru Runtime Certified Edition.

IBM J9 — IBM’s implementation of JRE, using OpenJ9 contributions.

Parrot VM — a VM with experimental support for Java [1] through two different methods: either as a Java VM bytecode translator, or as a Java compiler targeting the Parrot VM.

Development tools

For integrated development environments, see List of applications#Integrated development environments and the Java IDEs subsection specifically.

To discourage reverse engineering an obfuscator like proguard AUR can be used.

Decompilers

  • Bytecode Viewer — Java reverse engineering suite, including a decompiler, editor and debugger.

https://bytecodeviewer.com || bytecode-viewerAUR

  • CFR — Java decompiler, supporting modern features of Java 9, 10 and beyond.

https://www.benf.org/other/cfr/ || cfrAUR

  • Fernflower — Analytical decompiler for Java, developed as part of IntelliJ IDEA.

https://github.com/JetBrains/intellij-community/tree/master/plugins/java-decompiler/engine || fernflower-gitAUR

  • JAD — Unmaintained Java decompiler (last release 2006).

https://varaneckas.com/jad || jad

  • Java Decompiler (JD-Core, JD-GUI) — Popular Java decompiler providing a GUI and supporting Java 1-10.

https://java-decompiler.github.io/ || jd-guiAUR

  • Krakatau — Java decompiler, assembler, and disassembler.

https://github.com/Storyyeller/Krakatau || krakatau-gitAUR

  • Procyon decompiler — Experimental Java decompiler, inspired by ILSpy and Mono.Cecil.

https://bitbucket.org/mstrobel/procyon/wiki/Java%20Decompiler || procyon-decompilerAUR , GUI: luytenAUR

Switching between JVM

The helper script archlinux-java provides such functionalities:

List compatible Java environments installed

Note the (default) denoting that java-7-openjdk is currently set as default. Invocation of java and other binaries will rely on this Java install. Also note on the previous output that only the JRE part of OpenJDK 8 is installed here.

Change default Java environment

Note that archlinux-java will not let you set an invalid Java environment. In the previous example, jre8-openjdk is installed but jdk8-openjdk is not so trying to set java-8-openjdk will fail:

Unsetting the default Java environment

There should be no need to unset a Java environment as packages providing them should take care of this. Still should you want to do so, just use command unset :

Fixing the default Java environment

If an invalid Java environment link is set, calling the archlinux-java fix command tries to fix it. Also note that if no default Java environment is set, this will look for valid ones and try to set it for you. Officially supported package «OpenJDK 8» will be considered first in this order, then other installed environments.

Launching an application with the non-default java version

If you want to launch an application with another version of java than the default one (for example if you have both version jre7 and jre8 installed on your system), you can wrap your application in a small bash script to locally change the default PATH of java. For example if the default version is jre7 and you want to use jre8:

Package pre-requisites to support archlinux-java

This section is targeted at packager willing to provide packages in AUR for an alternate JVM and be able to integrate with Arch Linux JVM scheme to use archlinux-java . To do so, packages should:

  • Place all files under /usr/lib/jvm/java-$-$
  • Ensure all executables for which java-runtime-common and java-environment-common provide links are available in the corresponding package
  • Ship links from /usr/bin to executables, only if these links do not already belong to java-runtime-common and java-environment-common
  • Suffix man pages with -$$ to prevent conflicts (see jre8-openjdk file list where man pages are suffixed with -openjdk8 )
  • Do not declare any conflicts nor replaces with other JDKs, java-runtime , java-runtime-headless nor java-environment
  • Use script archlinux-java in install functions to set the Java environment as default if no other valid Java environment is already set (ie: package should not force install as default). See officially supported Java environment package sources for examples

Also please note that:

  • Packages that need any Java environment should declare dependency on java-runtime , java-runtime-headless or java-environment as usual
  • Packages that need a specific Java vendor should declare dependency on the corresponding package
  • OpenJDK packages now declare provides=»java-runtime-openjdk=$» etc. This enables a third-party package to declare dependency on an OpenJDK without specifying a version

Troubleshooting

MySQL

Due to the fact that the JDBC-drivers often use the port in the URL to establish a connection to the database, it is considered «remote» (i.e., MySQL does not listen to the port as per its default settings) despite the fact that they are possibly running on the same host, Thus, to use JDBC and MySQL you should enable remote access to MySQL, following the instructions in MariaDB#Grant remote access.

IntelliJ IDEA

If IntelliJ IDEA outputs The selected directory is not a valid home for JDK with the system Java SDK path, you may have to install a different JDK package and select it as IDEA’s JDK.

Impersonate another window manager

You may use the wmname from suckless.org to make the JVM believe you are running a different window manager. This may solve a rendering issue of Java GUIs occurring in window managers like Awesome or Dwm or Ratpoison. Try set «compiz» or «LG3D»

You must restart the application in question after issuing the wmname command.

This works because the JVM contains a hard-coded list of known, non-re-parenting window managers. For maximum irony, some users prefer to impersonate LG3D , the non-re-parenting window manager written by Sun, in Java.

Illegible fonts

In addition to the suggestions mentioned below in #Better font rendering, some fonts may still not be legible afterwards. If this is the case, there is a good chance Microsoft fonts are being used. Install ttf-ms-fonts AUR .

Missing text in some applications

If some applications are completely missing texts it may help to use the options under #Tips and tricks as suggested in FS#40871.

Gray window, applications not resizing with WM, menus immediately closing

The standard Java GUI toolkit has a hard-coded list of «non-reparenting» window managers. If using one that is not on that list, there can be some problems with running some Java applications. One of the most common problems is «gray blobs», when the Java application renders as a plain gray box instead of rendering the GUI. Another one might be menus responding to your click, but closing immediately.

There are several things that may help:

  • For jre7-openjdk or jre8-openjdk , append the line export _JAVA_AWT_WM_NONREPARENTING=1 in /etc/profile.d/jre.sh . Then, source the file /etc/profile.d/jre.sh or log out and log back in.
  • For last version of JDK append line export AWT_TOOLKIT=MToolkit in

/.xinitrc before exec window manager.
Also, we can try to use wmname with line wmname compiz in your

/.xinitrc .

  • For Oracle’s JRE/JDK, use SetWMName. However, its effect may be canceled when also using XMonad.Hooks.EwmhDesktops . In this case, appending >> setWMName «LG3D» to the LogHook may help.
  • For sway, export _JAVA_AWT_WM_NONREPARENTING=1 may solve the problem.
  • See [2] for more information.

    System freezes when debugging JavaFX Applications

    If your system freezes while debugging a JavaFX Application, you can try to supply the JVM option -Dsun.awt.disablegrab=true .

    JavaFX’s MediaPlayer constructor throws an exception

    Creating instance of MediaPlayer class from JavaFX’s sound modules might throw following exception (both Oracle JDK and OpenJDK)

    which is a result of some incompatibilities of JavaFX with modern ffmpeg build delivered within Arch Linux repository.

    Working solution is to install ffmpeg-compat-55 AUR .

    If a Java application is not able to open a link to, for example, your web browser, install gvfs . This is required by the Desktop.Action.BROWSE method. See [3]

    Error initializing QuantumRenderer: no suitable pipeline found

    Possible issues / solutions:

    • GTK2 is missing. Install gtk2
    • OpenJFX is missing. Install java-openjfx

    Tips and tricks

    Behavior of most Java applications can be controlled by supplying predefined variables to Java runtime. From this forum post, a way to do it consists of adding the following line in your

    /.bash_profile (or /etc/profile.d/jre.sh to affect programs that are not run by sourcing

    For example, to use system anti-aliased fonts and make swing use the GTK look and feel:

    Three such variables exist, the options which are explained later in the table below take priority.

    JAVA_TOOL_OPTIONS Affects applications as well as tools like javac or the jshell.
    JDK_JAVA_OPTIONS Affects applications (everything started via the java command). Requires Java 9.
    (command line options) Arguments specified before the «class name» argument are Java options.
    _JAVA_OPTIONS The old way, affects applications and tools.

    Better font rendering

    Both closed source and open source implementations of Java are known to have improperly implemented anti-aliasing of fonts. This can be fixed with the following options: -Dawt.useSystemAAFontSettings=on , -Dswing.aatext=true

    See Java Runtime Environment fonts for more detailed information.

    Silence ‘Picked up JDK_JAVA_OPTIONS’ message on command line

    Setting the JDK_JAVA_OPTIONS environment variables makes java (openjdk) write to stderr messages of the form: ‘Picked up JDK_JAVA_OPTIONS=. ‘. To suppress those messages in your terminal you can unset the environment variable in your

    /.bashrc and alias java to pass those same options as command line arguments:

    Non interactive shells, like the launcher scripts for Java programs, (usually) do not read the

    /.bashrc , but still inherited exported variables from their parent process (which in turn inherited it at some point from the login shell which read the

    /.bash_profile ). As for the cases when they do, one put’s generally a statement at the op of the

    /.bashrc to avoid the file being read. That way, the variables are passed to programs launched via the desktop menu and in the case of an interactive shell where the message would disturb aliases are used instead (which in turn cannot be used in scripts).

    GTK LookAndFeel

    If your Java programs look ugly, you may want to set up the default look and feel for the swing components:

    Some Java programs insist on using the cross platform Metal look and feel. In some of these cases you can force these apps to use the GTK look and feel by setting the following property:

    GTK3 Support

    In Java releases prior to version 9, the GTK LookAndFeel is linked against GTK2, whilst many newer desktop applications use GTK3. This incompatibility between GTK versions may break applications utilizing Java plugins with GUI, as the mixing of GTK2 and GTK3 in the same process is not supported (for example, LibreOffice 5.0).

    The GTK LookAndFeel can be run against GTK versions 2 , 2.2 and 3 , defaulting to GTK3. This can be overridden by setting the following property:

    Better 2D performance

    Switching to OpenGL-based hardware acceleration pipeline will improve 2D performance

    Источник

    Читайте также:  Dtb файл linux что это
    Оцените статью