The path system variable in Windows and the CLASSPATH environment variable in java.

Source: Internet
Author: User
Tags microsoft sql server

Setting path in Windows tells the system what path the executable file is placed on.

The set CLASSPATH is the path that tells the JVM what class to use or execute.

Take my own machine for example.

JAVA_HOME=C:/J2SDK1.4.2_06//I install the JDK path.

Classpath=.; %java_home%/lib;%java_home%/lib/dt.jar;%java_home%/lib/tools.jar
Some of the toolkits that are brought in the JDK. Notice.; It's important. He told the JVM to look for it from the current directory. This is not like windows,windows default is to find from the current directory first

Path=%systemroot%/system32;%systemroot%;%systemroot%/system32/wbem; C:/Program Files/ati Technologies/ati Control Panel; C:/Program Files/microsoft SQL Server/80/tools/binn;%java_home%/bin

I added at the back;%java_home%/bin this is the path to the JAVA executable file Java.exe Javac.exe, and so on. Because Windows first finds a running file in the current directory, it is found in the path directory if it is not found. That's why we're adding%java_home%/bin to the path, and now we can run JAVA javac anywhere.

In a newer version of the SDK, you do not need to set the SDK's original class or Jar path in classpath. The program has been set up for you, you just need to add a few other packages as well.

From the Java link version

Author: Taho (Fool person) Kanban: Java
Title: PATH & CLASSPATH
Time: Mon 28 23:18:06 2002

Look, this problem is starting to come out again.

If you have a DOS system, you should be able to understand what PATH is doing.
This PATH is not for Java
This is something that has been in the early DOS era without Windows ...
Because DOS does not have a so-called "shortcut"
So if you're going to perform the stroke, you have to give him the full path.
Unless the program is in the user's right eye

For example, say C:/windows/commands/edit.exe
If you are in
c:/windows/commands> edit
, you can
if you are in
c:/> edit
He'll tell you he can't find this edit.exe
because this file is not in c:/. Underneath
You can't expect the computer to search all your hard disk records to find a possible file
If that's not long before your hard drive can start to break.
so you have to play the full path
C:> c:/windows/commands/ Edit
But it's so annoying every time.
So it turns out a "system variable", which is the setting that the OS is going to use.
Just set path=c:/windows/commands/
that doesn't matter where you hit edit, He's going to go find out if there's a program under the current record
If you don't have a path to find ....
Of course not only edit, as long as any instructions can not be found under the current record
He will go to the PATH set to find the
so you understand why you want to set to the JDK's bin record?
because Java.exe and Javac.exe and so on are under this catalogue
so after you install the JDK, there are three options to execute the command
1. Direct to the Javac.exe Java.exe under the catalogue to play instructions (troubles ...)
2. Always play the full path (usually very long ...) with each command.
3. Set system change PATH to JDK's bin catalogue

The same so-called JVM is like activating an OS on the OS
For the JVM, CLASSPATH is like a PATH to the OS.
The JVM was inspired by Java.exe this program
And don't forget that java.exe is not in the user's path.
So he's going to go down to Java.exe's catalogue. class file
Unless your. class file is in the same video as Java.exe.
Otherwise he couldn't find. class where ....
So we're going to set a path so that the JVM can go this way to find what you want him to do. class
So there are three ways you can perform
1. Put all the. Classes under Java.exe (difficult to manage ...)
2. Always play the full path, that is, use the-CP option
such as JAVA-CP.; C:/myclass/test
(which is the point where the user plays the command)
(often playing is very troublesome ...)
3. Set the system variable CLASSPATH to the position of your class

As to how the system variables are set, depending on the platform you are on that platform,
(Of course system variables are not just these two, even if you don't have to set
Usually when the OS is installed, the OS predicts a bunch of system variables
You just put two more hands on it.

Of course you don't even have to set it.
It's just a hassle.
For example, the path you install is
C:/jdk1.3.1/
D:/myclass/test.class
Where Test is used to E:/extclass/util.class
Then you have to play every time.
C:/JDK1.3.1/BIN/JAVA-CP E:/extclass;d:/myclass Test
If you're not too bothered, it's no use setting.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.