0
Explore
0

Can You See java -version in CMD Without Setting Environment Variable?

Updated on July 23, 2025

Yes, but it depends on how Java was installed.

Case 1: You Installed Java with an Installer (like Oracle JDK)

Most modern Java installers (like Oracle JDK or Amazon Corretto) automatically set the environment variables for you during installation. So, after installation:

You can open CMD and type:

java -version

and you’ll see something like:

java version "21.0.1" 2023-10-17 LTS
Java(TM) SE Runtime Environment...
Java HotSpot(TM) 64-Bit Server VM...

This means Java is added to your system’s PATH automatically.

Case 2: You Unzipped a Portable JDK (or used a manual setup)

If you downloaded a .zip or .tar.gz version and extracted it manually without running an installer, Java will not be added to the PATH. In this case:

Running java -version in CMD will give an error:

'java' is not recognized as an internal or external command...

🛠️ You must set the PATH manually using environment variables.

🔧 How to Set Environment Variable Manually (For Windows)

1. Copy your Java installation path:
Example:

C:\Program Files\Java\jdk-21\bin

2. Search for “Environment Variables” in the Windows search bar.

3. Click Edit the system environment variables → Click Environment Variables.

4. Under System Variables → select Path → click Edit → click New → paste your path.

5. Click OK on all windows.

6. Open a new CMD window (important) and run:

java -version
javac -version

Summary Table

SituationCan you run java -version in CMD?Action
Used Java Installer✅ YesNo need to set manually
Extracted ZIP version❌ NoSet PATH manually
PATH already includes Java✅ YesYou’re good to go
PATH doesn’t include Java❌ NoAdd Java to PATH