Why do I need to set environment variables and user variables sometimes when building a compilation environment?
Environment variables include system environment variables and user environment variables.
Environment variables are system environment variables that work for all users.
The user environment variables only work for the current user.
For example, if you want to use Java, add the bin directory of Java to the PATH variable, which is the system environment variable, which is logged on by the user, if you enter Java in the command line, Java help information is provided. If you create a new variable under a user's variable, it is only useful to this user. When you log on to another user, this variable is the same as it does not exist.
This problem is easier to understand in Linux. The system variables are in the/etc/profile file, while the user variables are in ~ /. Bash_profile (if Bash is used), the user directory of each user is invisible to other users. Suppose there are three users A, B, and C. You write a statement in the variable file of a to output A on the screen. In the output file of B and C, nothing is output, system File output SYS. When user a logs on to the system, user a logs on to user B and user C logs on to user SYS.
Supplement:
In Windows, few environment variables are used. For example, if you want to use only JDK instead of JBuilder, you have to set the JDK path, classpath, and other environment variables by yourself.
In Linux, the files are automatically generated by the system. You can manually change them to achieve what I have mentioned. These are the settings of Java environment variables in Windows that run automatically upon login by their respective users.
In Windows, Java mainly uses three environment variables: java_home, classpath, and path. The following analysis is performed one by one.
Java_home points to the JDK installation path, such as X: \ jdk_1.4.2. In this path, you should be able to find the bin, Lib, and other directories. It is worth mentioning that you can select any disk directory for the JDK installation path, but we recommend that you have a lower directory level. If you have a deep directory, such as X: \ xxxxxx \ XXXXX \ XXXX \ XXX ......
Then, you will be tired of the following steps and future applications. Setting method:
Java_home = x: \ jdk_1.4.2
The path environment variable exists in Windows. You only need to modify it to point it to the JDK bin directory, in this way, you do not need to enter a large string of paths when compiling and executing programs in the console. The setting method is to keep the original path content and add % java_home % \ bin to it.
(Note: If you do not know about the DOS batch processing, you may not understand the meaning of the content caused by %. In fact, the environment variable java_home set in the previous step is referenced here, you can also write X: \ jdk_1.4.2. You can open a console window and enter echo
% Java_home % ):
Path = % java_home % \ bin; % PATH %
Similarly, % PATH % references the previously set path environment variable. You just copy the previous value.
I put the classpath environment variables at the end, because you may encounter inexplicable and strange problems later. More than 80% may be caused by incorrect classpath settings, so be careful.
Classpath =. \; % java_home % \ Lib \ tools. Jar
The first thing to note is the front ". \;". If you cannot see it clearly, I will read it for you-the backslash. This tells JDK to first find the class file in the current directory when searching for the Class-why? This is caused by the Linux security mechanism. Linux users understand it very well, windows users are hard to understand (because the default search order in Windows is to search the current directory first, then the system directory, and then the PATH environment variable)
So if you like Linux, you may want to study Linux.
Why is the specific file tools. Jar specified after classpath? Not specified? Obviously, no. I can do that again! :)
This is determined by the import mechanism and jar mechanism of the Java language. You can check the information to solve this problem.
The specific setting method is as follows: Right-click my computer and choose Properties> advanced> environment variable to modify the value in the system variable box below.
The Win9x user modifies the autoexec. BAT file and adds it to the end:
Java_home = x: \ jdk_1.4.2 \ bin;
Path = % java_home %; % PATH %;
Classpath =. \; % java_home % \ Lib \ tools. Jar
Right-click my computer-properties-advanced-environment variables-Create an environment variable (double-click a path to change the value ):
Variable name: Path
Variable value (PATH): e: \ Java .. (name of your installation Java) \ bin