How to view, modify, delete, and add environment variables in the cmd command line

  
        

1. About the configuration of Java environment variables


Installing the JDK, such as the directory in C:\\Java

In order to facilitate the development of java programs, you need to configure the environment. Variable, right click on My Computer -> Properties -> Advanced -> Environment Variables -> User Variables Click [New (N)] to add the following environment variables

(assuming your JDK installation The path is C:\\Java\\jdk1.6.0_30)

JAVA_HOME C:\\Java\\jdk1.6.0_30

PATH C:\\Java\\jdk1.6.0_30\\bin

CLASSPATH .;%JAVA_HOME%\\lib\\dt.jar;%JAVA_HOME%\\lib\\tools.jar; (Note that the preceding dot and semicolon must not be lost, there is also the middle, the back of the semicolon should not be lost ))

Description: CLASSPATH can add some third-party jar files, which is convenient for manually compiling and running programs.

After you have created each one, you can test it.

Description: If the computer just uses the above variables, it is recommended to set it as a user variable.

A simple test program can be written by means of Notepad and other tools, saved in d:\\, the code is as follows:

?public class Test { public static void main(String[] args) { System.out.println("Hello java!"); } }


Description: When saving, pay attention to the same file name and class name and file suffix name (.java)< Br>

Run cmd, enter the DOS interface, run java -version, if the above environment is configured correctly, the current JDK version information should be displayed. (You can run this command in any directory)

Run javac d:\\Test.java, and press Enter to compile the generated file Test.class in the same directory,

Run d: Enter D disk root directory,

Run java Text, enter the output Hello java!


Excerpt from ymmt

2. Environment variable definition

Environment variable is An object with a specific name that contains information that will be used by one or more applications. For example, path, when the system is required to run a program without telling the full path of the program, the system should look for the program in addition to the path specified in the path. Users can run processes better by setting environment variables.


3. View, modify


First of all, it is clear that all changes to environment variables in the cmd command line are only valid for the current window. , not a permanent modification. This means that when this cmd command line window is closed, it will no longer work. There are two ways to permanently modify environment variables: one is to modify the registry directly, and the other is to set the system environment variable through My Computer -> Properties -> Advanced.


Display, set, or delete the cmd.exe environment variable.

SET [variable=[string]]

variable Specifies the name of the environment variable. String Specifies a series of strings to assign to variables.

To display the current environment variable, type SET without parameters.



1. View all available environment variables: enter set to view.

2, view an environment variable: enter “set variable name & rdquo; can, for example, want to view the value of the path variable, that is, enter set path


4 .Windows and linux difference
First, view the names and values ​​of all environment variables: Linux: exportWindows: set two, check the value of the environment variable according to the name: Linux: echo $ environment variable name such as: echo $ORACLE_HOMEWindows Bottom: set environment variable name

Copyright © Windows knowledge All Rights Reserved