Environment Variables Configuration for Java and C
I reinstalled the system yesterday and upgraded to Win10 2004. I thought I could configure the environment variables for Java and C from memory, but in the end, I had to turn to Google for help. So, I'll document it again.
This post was translated from my Chinese blog post with the aid of ChatGpt.
Java
- Simply search for
environment variables
in the taskbar search box, and you will findEdit the system environment variables.
- In the popup window, click on
Environment Variables
in the bottom right corner. - Under
System variables,
create a new system variable with the variable nameJAVA_HOME
and the variable value as the installation path of JDK, which is typicallyC:\Program Files\Java\jdk-14.0.2
by default. - Create another system variable named
CLASSPATH
with the variable value as.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
. - Double-click on the
Path
variable in the system variables section, and clickNew
in the top right corner. - Add
%JAVA_HOME%\bin
and%JAVA_HOME%\jre\bin
separately. - Confirm and return to the desktop.
- Open the terminal and enter
java -version
to check if it was successful. If successful, it will display the Java version. - If it’s not successful, try restarting and double-check the variables for correctness.
C
- In Mingw, select
mingw32-base
andmingw-gcc-g++,
selecting more will lead to a very long installation process. You can select them by right-clicking and choosingMark for Installation.
- Click on
Installation
in the top right corner and chooseApply Changes.
- In the popup window, click
Apply
to confirm. - Wait patiently… Potato servers often report installation failures.
- After installation, follow the same steps to open system variables.
- Double-click on the
Path
variable in the system variables section, and clickNew
in the top right corner. - Add the installation path for Mingw, which is typically
C:\MinGW\bin.
- Open the terminal and enter
gcc -v
to check if it was successful. - If it’s not successful, try restarting.
Your environment variables should look something like this after configuration: