Java environment variable settings

xiaoxiao2021-03-06  41

Environment variables are indicifiect lights such as operating systems, applications, scripts, etc., which can tell them where the resources needed. mostly

There are some pre-set environment variables, of course, we can also increase your environment variables.

In order to see the current system's environment variable, we can use the following command:

On the Linux / UNIX system, enter ENV in the shell command, then use

In the Windows system, set SET in the DOS window prompt, and then carriage return

This way, we can see all environment variables in the system, if we want to see the value of a single variable?

On the Linux / UNIX system, enter the echo $ variable name at the shell command, and then carriage return

In the Windows system, enter the SET variable or Echo% variable% in the DOS window prompt, and then carriage return

If you want to set an environment variable, you can use the following command:

On the Linux / UNIX system, enter the export variable name = "variable value" at the shell commander, then enter the car

In the Windows system, enter the SET variable name = "Variable value" in the DOS window prompt.

This is set, it is set. The value of the PATH and CLASSPATH environment variables is some list of sequential directory. Tell the system or application

Where to find resources they need. This list is separated by a series of separators, and the separator under the Linux / UNIX system is a colon: "

The Windows system is a semicolon ";". If, we want to add some own values ​​to an existing environment variable, you can:

LINUX / UNIX system: export classpath = $ ClassPath: / Path / to / Program

Under Windows System: set classpath =% classpath%; C: / Path / TO / Program

Second, set the Java environment

To make it easy to develop and run the Java application, we need to set up two environment variables, a PATH ClassPath.

Set good path variables so that we can run Java applications anywhere in the system, such as Javac, Java, Javah, etc.

This is to find the directory we have installed JDK, such as our JDK installation in the c: /jdk1.3/ directory, then in the C: /JDK1.3/bin directory

Next, we often use the Java application, we need to add this directory to the PATH environment variable.

ClassPath environment variable, is when we need to quote someone to write a class when developing a Java program, let Java interpreter know where

Go find this class. Typically, Sun provides us with some extra rich classes, one is dt.jar, one is Tools.jar, these two JAR packs

Usually in the cat directory of the c: /jdk1.3/lib, usually we will add these two JAR packages into our ClassPath environment variables.

Set classpath = .; c: /jdk1.3/lib/tools.jar; c: /jdk1.3/lib/dt.jar. Pay attention to the JAR package in ClassPath

Need to keep up with the full file path, not just following a directory. The first path ".", Represents the current directory, so when we run Java ACLASS

When it is, the system will look for the ACLASS file in the current directory.

转载请注明原文地址:https://www.9cbs.com/read-51896.html

New Post(0)