How to Configure Java Environment Variables
The steps for configuring Java environment variables are as follows:
- Download and install the Java Development Kit (JDK): First, you need to download the JDK installer for your operating system from the Oracle official website (https://www.oracle.com/java/technologies/javase-jdk11-downloads.html) and follow the prompts to install. Once the installation is complete, remember the installation path.
- To set the JAVA_HOME variable, create a new system environment variable called JAVA_HOME with the value being the installation path of the JDK. To do this, right-click on Computer -> Properties -> Advanced system settings -> Environment Variables, then click on “New” in the System Variables section. Enter JAVA_HOME as the variable name and the JDK installation path as the variable value.
- To set the Path variable, add the JDK bin directory path to the Path variable in the system environment variables. Specifically, locate the Path variable in the system variables, click “Edit,” and add “;%JAVA_HOME%\bin” at the end of the variable value.
- Verify the Java environment variable configuration by opening the command prompt, entering the commands “java -version” and “javac -version”, if the Java version information is displayed, it means the Java environment variable configuration is successful.
By following the above steps, you can successfully set up Java environment variables and start developing and running Java programs on your computer.