Check Your Java Installation
Before we dive into Java coding, we need to make sure we have a recent Java version installed.
Tip: Any Java version 11 or higher will be fine for getting started with Java today.
Step 1. Open a Terminal Window.
- On Windows, click Start, type
cmd, and hit Enter.
- On Mac OS X, go to Launchpad, and search for "Terminal".
- On Linux, go to Applications and search for "Terminal".
Step 2. In the Terminal, enter the command
You should get output similar to the below.
java -version openjdk version "17.0.5" 2022-10-18 LTS OpenJDK Runtime Environment Zulu17.38+21-CA (build 17.0.5+8-LTS) OpenJDK 64-Bit Server VM Zulu17.38+21-CA (build 17.0.5+8-LTS, mixed mode, sharing)
Make sure that the version shown above in your Terminal is any Java version 11 or higher.
In this case, you have OpenJDK installed and you're all set to run and write Java code.
If you get any of the following results, instead of the above, you need to install OpenJDK.
'java' not recognized as an internal or external command, operable program or batch file.
command not found: java
Command 'java' not found, did you mean...
Go to one of the following pages for details on installing OpenJDK: