Appearance
Quick Start
Download JDK
Since Java programs must run on top of the JVM, the first thing we do is install the JDK.
Search for JDK 23 and make sure to download the latest stable version of the JDK from Oracle's website:
Select the appropriate operating system and installation package, find the download link of Java SE 23, Download and download and install it.
Windows preferred x64 MSI Installer , Linux and macOS should choose the appropriate installation package according to whether the CPU of their computer is ARM or x86.
Set Environment Variables
After installing the JDK, you need to set an environment variable for the JAVA_HOME
, which points to the directory where the JDK is installed. Under Windows, it's the installation directory, something like:
sh
C:\Program Files\Java\jdk-23
Under Mac, it's ~/.bash_profile
~/.zprofile
in or , and it's:
sh
export JAVA_HOME=`/usr/libexec/java_home -v 23`
Then, append JAVA_HOME the bin directory to PATH the system environment variables. Under Windows, it looks like this:
sh
Path=%JAVA_HOME%\bin;<other>
Under Mac, it's ~/.zprofile
in ~/.bash_profile
or , looks like this:
sh
export PATH=$JAVA_HOME/bin:$PATH
Add JAVA_HOME
PATH the bin directory of to in order to run it in any folder java . Open a command prompt window, type in java -version
the command, and if everything looks good, you'll see an output like this:
sh
Microsoft Windows [Version 10.0.0]
(c) 2015 Microsoft Corporation. All rights reserved.
C:\> java -version
java version "23" ...
Java(TM) SE Runtime Environment
Java HotSpot(TM) 64-Bit Server VM
C:\>
If you see a version number that is not 23 , but 15 1.8 , , etc., it means that there are multiple JDKs in the system, and the default JDK is not JDK 23, and you need to mention JDK 23 PATH in front.
If you get an error output:
sh
Microsoft Windows [Version 10.0.0]
(c) 2015 Microsoft Corporation. All rights reserved.
C:\> java -version
'java' is not recognized as an internal or external comm
and, operable program or batch file.
C:\>
This is because the system is unable to find the Java Virtual Machine program java.exe and needs to check JAVA_HOME
PATH the configuration of and .
For reference, refer to How to Set or Change the PATH System Variable.
JDK
Attentive children's shoes can also find a lot of executable files in JAVA_HOME
the bin directory:
- java: This executable program is actually the JVM, running a Java program is to start the JVM, and then let the JVM execute the specified compiled code;
- javac: This is the Java compiler, which is used to compile Java source files (ending with
.java
suffix) into Java bytecode files (ending with.class
suffix); - jar: used to package a set of
.class
files into a.jar
single file for easy publishing; - javadoc: used to automatically extract comments from Java source code and generate documents;
- jdb: Java debugger, used for running debugging in the development phase.