If your java version more than 1.6 then it should work

java -version

if version is not installed it returns error message

Please share some snapshot so i can rectify it

Answer from iamsankalp89 on Stack Overflow
🌐
Oracle
java.com › de › download › help › version_manual.html
Wie finde ich die Java-Version in Windows oder Mac – Manuelle Methode
Sie können die JDK-Standardversion bestimmen, indem Sie java -version in einem Terminalfenster eingeben. Wenn die installierte Version 7u55 lautet, wird eine Zeichenfolge angezeigt, die den Text 1.7.0_55 beinhaltet.
People also ask

Does `java -version` show the JDK or the JRE?
It shows whichever runtime is set as the default. Both the JRE-only package and the full JDK include the `java` command. To confirm that the JDK is installed, check for `javac` as described above.
🌐
linuxize.com
linuxize.com › home › java › how to check java version
How to Check Java Version | Linuxize
How do I check the Java version inside a shell script?
Parse the output of `java -version`, which prints to standard error: ```bash java -version 2>&1 | head -n 1 | awk -F '"' '{print $2}' ``` This returns a string such as `21.0.4` that you can compare in your script.
🌐
linuxize.com
linuxize.com › home › java › how to check java version
How to Check Java Version | Linuxize
🌐
LinuxConfig
linuxconfig.org › home › check java version
How to Check Java Version
June 3, 2020 - There are several ways on how to check what version of Java is installed on your system. Most likely the simplest way is to directly use the java binary in combination with the -version option.
🌐
Delft Stack
delftstack.com › home › howto › java › check java version in java
How to Check Java version | Delft Stack
March 4, 2025 - Linux users can open the terminal from their application menu. Once the command line is open, type the following command: ... After entering the command, press Enter. ... java version "17.0.1" 2021-10-19 LTS Java(TM) SE Runtime Environment (build 17.0.1+12) Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12, mixed mode)
🌐
Oracle
java.com › de › download › help › linux_x64_install.html
Anweisungen zur Installation von Java für 64-Bit-Linux
Die folgenden Anweisungen gelten für die Installation von Java 8 Update 73 (8u73). Wenn Sie eine andere Version installieren, müssen Sie bei der Eingabe der Befehle am Terminal die entsprechende Versionsnummer verwenden. Beispiel: Bei Java 8u79 ersetzen Sie 8u73 durch 8u79.
🌐
LinuxBuz
linuxbuz.com › linuxhowto › check-java-version-linux
How to Check Java Version On Linux | Ubuntu/Debian/CentOS - LinuxBuz
March 10, 2024 - In this post, we will show you different methods for how to check Java version on Ubuntu, Debian and CentOS operating system.
🌐
GeeksforGeeks
geeksforgeeks.org › linux-unix › how-to-check-java-version-in-linux
How to Check Java Version in Linux - GeeksforGeeks
July 23, 2025 - In your linux command terminal, type the following java command and press Enter: ... This command will display the Java version installed on your system.
Find elsewhere
🌐
Linuxize
linuxize.com › home › java › how to check java version
How to Check Java Version | Linuxize
March 29, 2026 - Find out which Java version is installed on your system, check the JDK compiler version, and manage multiple Java installations from the command line.
🌐
Deep Java
digibeatrix.com › home › development environment setup › how to check your java version (windows, macos, linux): java -version & javac -version
How to Check Your Java Version (Windows, macOS, Linux): java -version & javac -version - Deep Java
January 5, 2026 - Learn how to check the Java version actually being used on Windows, macOS, and Linux. Use java -version and javac -version, identify PATH/JAVA_HOME issues, and fix “wrong version” problems.
🌐
Linux Hint
linuxhint.com › check-java-version-linux-ubuntu
How to check Java Version on Linux Ubuntu – Linux Hint
Given below are certain commands you can use to check your version alongside other important things. ... Press “Y” followed by “ENTER” and the package will be uninstalled. To run Java programs, you’ll need JRE (Java runtime environment). It is compatible with Windows, Linux, Mac, Solaris, and many more.
Top answer
1 of 4
121

The simplest way is:

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.

2 of 4
43

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:

file `which java javac`

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.

🌐
Linux.org
linux.org › home › forums › general linux forums › general linux topics
Check Java version from Command Line | Linux.org
May 28, 2020 - you can do a few things: bash-5.0$ java -version java version "1.8.0_231" Java(TM) SE Runtime Environment (build 1.8.0_231-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode) bash-5.0$ bash-5.0$ bash-5.0$ which java /usr/lib64/java/bin/java bash-5.0$ echo $JAVA_HOME /usr/lib64/java bash-5.0$ also slackware: ls /var/log/packages | grep jdk jdk-8u231-x86_64-1_SBo bash-5.0$ so i have 8u231 installed
🌐
Kernelhost
kernelhost.com › cp › knowledgebase › 3 › Java-8-or-Java-11-auf-Ubuntu-22.04-or-Ubuntu-20.04-installieren-.html
Java-8 / Java-11 auf Ubuntu 22.04 / Ubuntu 20.04 installieren - Knowledgebase - KernelHost GmbH
Wichtig ist, dass Sie am Ende ebenfalls überprüfen, ob die Installation erfolgreich war. Dies können Sie einfach kontrollieren, indem Sie die Java-Version abfragen.
🌐
LinuxVox
linuxvox.com › blog › how-to-check-java-version
How to Check Java Version: A Comprehensive Guide — linuxvox.com
In the Java Control Panel, go to General > About to view the version. Linux distributions (e.g., Ubuntu, Fedora, CentOS) use the terminal for most system tasks, including checking Java version.
🌐
Kernelhost
kernelhost.com › cp › knowledgebase › 149 › Install-Java-21-on-Debian-12.html
Java 21 auf Debian 12/11/10 installieren - Wissensdatenbank - KernelHost GmbH
Um Java-21 als Default Java-Version zu setzen, müssen Sie lediglich die Java-21 Version aus der Liste auswählen. Ein Beispiel wäre wie folgt: sudo update-java-alternatives --set /usr/lib/jvm/jdk-21-oracle-x64 · Nun können Sie wieder die Java-Version überprüfen:
🌐
Heiko-evermann
heiko-evermann.com › so-kannst-du-deine-java-version-ueberpruefen-und-die-verwendete-jre-finden
So kannst du deine Java-Version überprüfen und die verwendete JRE finden | Heiko Evermanns Entwicklerblog
March 27, 2023 - Manchmal ist es wichtig, deine Java-Version und den Pfad deiner Java Runtime zu kennen. Möglicherweise hast du verschiedene Java-Versionen auf deinem Computer und dein Programm…
🌐
Com
qastack.com.de › superuser › 569633 › what-is-command-to-see-all-java-versions-installed-on-linux
Was ist der Befehl, um alle Java-Versionen unter Linux zu sehen?
@ LeeMeadorfind /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' — Tink ... Sie lassen viel zu wünschen übrig, was die Details Ihres Setups angeht. Java kann unter Linux auf verschiedene Arten installiert werden.