How to Configure Java Environment Variables for Novices

by Miles Warren

The development of Java language from the initial to now still maintain good application. Therefore, it attracts many people to invest in Java software development. For many novices, the main problem is Java environment variable configuration. In fact, the environment configuration of Java is not so complicated. But it is more difficult for those who have just started. Next, we will tell you how to configure Java environment variables.

Step 1: To configure Java environment variables, you must install the JDK [Java (TM) se development kit]. And then you can start the relevant configuration. Finally, execute the downloaded JDK installation package. In order to avoid unnecessary conflicts, you can keep default installation path during installation process. Click "next" to confirm whether the "necessary" functions have been installed.

Step 2: After the JDK installation is completed, program needs to be tested . It aims to check whether installation is completed correctly. Then click the start menu, select "run...". And enter CMD in the command box and press enter to run. If it is installed correctly, a session box with black background will pop up. Enter "java version" at the command prompt and press enter. At this time, the information of program will be displayed in session box. It means that the installation is successful.

Step 3: Now start to configure the environment variables. Right click my computer and select properties, advanced system settings, and environment variables. Then click "new system variable" under the system variable column. And enter "JAVA_HOME" in the variable name of the session box. Enter the JDK installation path (the previous default path) in the variable value, and click OK.

Look for the variable "path" in the system variable options bar. If not, you need to create a new system variable. Otherwise, select edit system variable. In the pop-up session box, add "%JAVA_HOME%in;%JAVA_HOME%jrein". It’s at the beginning of the variable value text box. Or direct to "%JAVA_HOME%in", then click OK.

Then find out whether there is a variable "CLASSPATH" in the options bar. If not, you need to create a new system variable. Otherwise, you can also select edit system variable . And enter it in the "variable value" of the dialog box. ".;%JAVA_HOME%libdt.jar;%JAVA_HOME%lib ools.jar",then click OK.

Finally, test whether the environment variables are configured successfully. And enter "javac" in the black background dialog box to run. If successful, a series of help messages will be output. Maybe there is an error and fails to install successfully. Then you can delete several newly created system variables. And you can recreate them according to the steps.

Step 4: compile a java program and compile it. During the compilation process, the following problems usually occur:
1. After inputting "javac ", an error is reported. And it shows that " is not an internal or external command, nor a runnable program or batch file". This is because the installation path is on Disk C by default. If the file to be compiled is not in Disk C, you need to import path to the disk. If the compiled file is stored in disk e, enter "e" after "C: user / Administrator...". Then the path will be imported into disk E. And input the corresponding instructions to compile.
2. In the case of problem 1 or no problem 1, if you still can't compile it. Then you can consider putting compiled file directly in root directory of the disk.
3. After first compilation, system should generate a .Class file with same name in the directory of compiled file. At this point, you should compile the .Class file again. And enter the command "Java < file name >" to complete the compilation.

Through the above steps, I believe you will certainly learn Java environment variable configuration. I hope the above information can help you.

Leave a Comment