I have a Java installation and I have only access via bash. How can I check the Java version from command line.

Dani AI

Generated

The thread title says Python but the question is about Java. asked how to check the Java runtime from a bash shell; and pointed to Python by mistake, and correctly noted that the Java executable itself reports its version. The steps below show how to locate the Java binary that will run, how to find installed JDK/JRE packages, and how to confirm which installation is active on Debian/RHEL-style systems.

First determine which java will be invoked by the shell:

command -v java

If that returns a path, follow symlinks to the real binary (this reveals vendor and installation directory):

readlink -f $(command -v java)

If nothing is returned, Java is not on your PATH. Check the environment variable commonly used for installs:

echo $JAVA_HOME

And inspect typical system install locations:

ls -l /usr/lib/jvm

To see distro-packaged installations, query the package database. On Debian/Ubuntu:

dpkg -l | grep -i jdk
dpkg -l | grep -i openjdk

On RHEL/CentOS:

rpm -qa | grep -i jdk

If your distro uses the alternatives system, display the active candidate (and its symlink targets) to know which install is currently in use:

update-alternatives --display java

Notes: a JRE may be present without the JDK (so compiler tools like javac might be missing). If a binary is not on PATH but installed, either add the appropriate bin directory to PATH or set JAVA_HOME. For distro-specific layout and the Java command reference see Oracle's tool documentation and the Debian Java wiki for packaging details: Oracle java tool reference and Debian: Java.

Recommended Answers

All 3 Replies

Not familiar with java but your thread title says python so at the command line just type python and the version will be displayed before the prompt. I'm curious as to why you included bash, linux, and mint as tags but not python or java.

How can I check the Java version from command line.

java -version

also a possible answer:
python --version

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.