Classpath's explanation

xiaoxiao2021-03-06  62

# Summary Class Path is the path to the Java execution period to search for categories and other resources. Class Search Path (usually known to compare this abbreviation name this) can be used to use -classpath when the SDK tool is called, or sets the ClassPath environment variable. It is recommended to use the -classpath option because you can set up separately for each application without affecting other applications, and there will be no other applications to change this value. C:> sdktool -classpath classpath1; classpath2 ...- or -c:> set classpath = classpath1; classpath2 ... on this: SDKTool: is a command column tool program, like Java, Javac or Javadoc.classpath1; ClassPath2: ClassPath Points .jar, .zip, or .Class file Class Path, each classpath should end with a file name or directory name (which is related to the ClassPath you want to set). * For a .jar or .zip file including .class, Class Path is to end with the name of the .zip or .jar file. * For an unnamed Package, the class path is to end with the directory of all .class files. * For a named Package, Class Path is to end with the directory name including "The First Package Name of the Full Package Name). Multiple path projects should be seized in a semicolon, using the set command, the important thing is that the equal sign cannot be blank. Preset Class Path is current directory, setting ClassPath variables or using the -classpath command option to overwrite this preset, so if you want to include the current directory in the current search path, you must include "" " ". That is, it is not a directory that is not the ClassPath of the file file (.zip or .java) will be ignored. # Description Class Path tells the SDK tool program to find where the third element (third-part) defined by the user, is also part of the non-Java extension kit or non-Java platform. When you use the Javac compiler to compile categories, you need to use Class Path to find any of the required suits - the preset is current directory to facilitate finding these categories. Java2 SDK, JVM and other SDK tools find the desired Classes by searching the Java platform, Classes, other extensions, classes, in this order (to understand the details of the search policy, see how to find Classes, How classes Are Found), the category library used by most applications can utilize the extensions mechanism, where you load a category of current directory or other subdirectories and they are not extended in the rendering kit, you What you want is to set Class Path. If you upgrade from the old version of the SDK, you may include the ClassPath settings that have no longer used in your boot settings, you must remove these non-specific applications, like classes.zip, some use to Java virtual The third component of the machine may change your ClassPath environment variable to include the program library they use, and these settings can be retained.

When you ask the JVM or other SDK tool program, you can change the Class Path when you use the Java tool program, or specify using the ClassPath environment variable. It is recommended to use the -classpath option to be better than setting the ClassPath environment variable because you can set separately for each application, without affecting other applications, and other applications do not change this value. Classes can be stored in the directory (data clip) or in the file file, the Classes of the Java platform is stored in RT.jar, to understand the details of the file file or how the Class Path is working, please see "Learn about the Class Path and Package Names later." Important, Note: Some older version of JDK software includes / CLASSES project in the preset Class Path, where the existence is used by JDK software, and should not be used by the application Classes. The application category should be placed other directories outside the JDK directory structure. In this way, new JDK will not force you to reinstall the application Classes, in order to be compatible with the old version, you must use / Classes directory as a category library, you can operate in the current version, but it is not guaranteed to operate in future versions. # Using the SDK Tool Protection-ClassPath option SDK Tool program Java, JDB, Javac with Javah has a -CLASSPATH project, when the tool program is executed, it is used to replace the path set by the classPath environment variable, change the CLASS Path setting This is a suggested option, because each application can have a self-designed Class Path without interference with other applications. The execution period Tool program Java also has a -CP option, this option is the quotation name of -classpath. For some quite special examples, Java and Javac have some projects that allow you to change their paths to find the exclusive category library, however most users have never needed to use them. # Using the ClassPath environment variable, it is recommended that you use the -classpath command option, just as mentioned above, this section will make you how to set the ClassPath environment variable, if you want to make such, or want to clean it before Install the settings left. Set the ClassPath: ClassPath environment variable can be modified by the SET command, the format is: set classpath = path1; path2 .... Path should start with a disk code, such as C: /, in this way, even if you switch to Another disk machine can also be found in Classes. (For example, if the path item starts in the slope, you are in the disk machine D:, then Classes will expect in d:, rather than c :) Clear ClassPath: If your ClassPath environment variable has been set to A value, but not correct, or your startup file or command manuscript is set to the wrong path, you can cancel the ClassPath settings: C:> set classpath = This instruction only cancels the current command Column prompt window ClassPath settings, you should delete or correct your startup settings to ensure that you will have the correct ClassPath settings in the next operation.

Changing the start setting: If the classpath is set to the system startup, the setting place will depend on the job system you are using: Homework system method: * Windows 95 and 98 Check the SET instruction in AutoExec.Bat * Others (Windows NT, Windows 2000, ....) Use the system tools in the console to set the classpath variable # Understand the Class Path and the Package Name Java's Classes is organized as Packages, which corresponds to the directory structure of the archive system, but unlike archive systems, whenever When you specify a package name, you specify the entire package name instead of a part name, for example, Java.awt.Button's Package name is specified using java.awt. For example, suppose you want a Java execution environment to find a class called Cool.class in the package name utility.myApp, if the path to the directory is C: / java / myclasses / utility / myApp, you want to set the Class Path to include C : / java / myclasses. To perform this app, you can use the following JVM instruction: c:> java -classpath c: / java / myclasses utility.myapp.cool When the application is executed, the JVM uses the Class Path setting to find any other defined Categories in Utility.myApp Package (it is used by Cool Categories). Note that the entire Package name specified in the command, for example, setting Class Path includes C: / Java / MyClasses / Utility and uses instruction java myapp.cool, which does not find Class. (You may think about what defines a Class's package name, the answer is part of the Class, and cannot be modified unless you re-compile it.) Note: An interesting result of a package specified mechanism is the same package Partial files can exist in different directories. For each class, the package name will be the same, but the path to each file will begin with different directories in Class Path.

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

New Post(0)