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 variablesin the taskbar search box, and you will findEdit the system environment variables. - In the popup window, click on
Environment Variablesin the bottom right corner. - Under
System variables,create a new system variable with the variable nameJAVA_HOMEand the variable value as the installation path of JDK, which is typicallyC:\Program Files\Java\jdk-14.0.2by default. - Create another system variable named
CLASSPATHwith the variable value as.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;. - Double-click on the
Pathvariable in the system variables section, and clickNewin the top right corner. - Add
%JAVA_HOME%\binand%JAVA_HOME%\jre\binseparately. - Confirm and return to the desktop.
- Open the terminal and enter
java -versionto 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-baseandmingw-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
Installationin the top right corner and chooseApply Changes. - In the popup window, click
Applyto confirm. - Wait patiently… Potato servers often report installation failures.
- After installation, follow the same steps to open system variables.
- Double-click on the
Pathvariable in the system variables section, and clickNewin the top right corner. - Add the installation path for Mingw, which is typically
C:\MinGW\bin. - Open the terminal and enter
gcc -vto check if it was successful. - If it’s not successful, try restarting.
Your environment variables should look something like this after configuration:
