Oracle java classes9/12/2023 ![]() For example, the class path entry mydir/* specifies all JAR files in the directory named mydir. ![]() For compatibility with earlier releases, applications that use the /classes directory as a class library run in the current release, but there is no guarantee that they will run in future releases.Ĭlass path entries can contain the base name wildcard character (*), which is considered equivalent to specifying a list of all of the files in the directory with the extension. That way, installing a new JDK does not force you to reinstall application classes. Application classes should be placed in a directory outside of the JDK directory hierarchy. That directory exists for use by the JDK software and should not be used for application classes. Note: Some earlier releases of the JDK had a /classes entry in the default class path. For more details about archives and information about how the class path works, see Class Path and Package Names. The Java platform classes are stored in rt.jar. See CLASSPATH Environment Variable.Ĭlasses can be stored in directories (folders) or in archive files. Using the -classpath option is preferred over setting the CLASSPATH environment variable because you can set it individually for each application without affecting other applications and without other applications modifying its value. You can change the class path by using the -classpath or -cp option of some Java commands when you call the JVM or other JDK tools or by using the CLASSPATH environment variable. Some third-party applications that use the Java Virtual Machine (JVM) can modify your CLASSPATH environment variable to include the libraries they use. You should remove any settings that are not application-specific, such as classes.zip. If you upgrade from an earlier release of the JDK, then your startup settings might include CLASSPATH settings that are no longer needed. You only need to set the class path when you want to load a class that is (a) not in the current directory or in any of its subdirectories, and (b) not in a location specified by the extensions mechanism. For details about the search strategy, see How Classes Are Found at Ĭlass libraries for most applications use the extensions mechanism. The JDK, the JVM and other JDK tools find classes by searching the Java platform (bootstrap) classes, any extension classes, and the class path, in that order. The default is the current directory to conveniently enable those classes to be found. The class path needs to find any classes you have compiled with the javac compiler. The class path tells the JDK tools and applications where to find third-party and user-defined classes that are not extensions or part of the Java platform. ) in the new settings.Ĭlass path entries that are neither directories nor archives (.zip or JAR files) nor the asterisk ( *) wildcard character are ignored. Setting the CLASSPATH variable or using the -classpath command-line option overrides that default, so if you want to include the current directory in the search path, then you must include a dot (. The default class path is the current directory. Multiple path entries are separated by semicolons with no spaces around the equals sign (=) in Windows and colons in Oracle Solaris. Each class path should end with a file name or directory depending on what you are setting the class path to, as follows:įor a JAR or zip file that contains class files, the class path ends with the name of the zip or JAR file.įor class files in an unnamed package, the class path ends with the directory that contains the class files.įor class files in a named package, the class path ends with the directory that contains the root package, which is the first package in the full package name. ![]() For a listing, see JDK Tools and Utilities at classpath1:classpath2Ĭlass paths to the JAR, zip or class files. ![]() sdkToolĪ command-line tool, such as java, javac, javadoc, or apt. ![]() SdkTool -classpath classpath1 classpath2. The -classpath option is preferred because you can set it individually for each application without affecting other applications and without other applications modifying its value. The class search path (class path) can be set using either the -classpath option when calling a JDK tool (the preferred method) or by setting the CLASSPATH environment variable. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |