What is the classpath of Java?

Source: Internet
Author: User

If you enter a command, such as
Java
So how did the system find the command?
In order, the system first searches in the current directory whether there are Java.exe, Java.bat and so on. If not, get the system path (case insensitive) to find.

For example, the path of your environment variable has C:\program Files\java\jdk1.6\bin
Then the system will try to find it under this directory and find the Java.exe then execute it.
So path is a parameter that the system configures to search for a resource. Multiple directories are separated by semicolons (a colon in Linux).

What about Classpath? In the same way, when we need a class, the system will automatically search in the classpath, if it is a jar, it will be automatically found from the jar, if it is a normal directory, then under the directory to find the package.
However, unlike path, the default classpath is not included in the current directory, which is the reason why the classpath contains a point.

The WEB app under Tomcat has two presets for classpath:web-inf/classes and Web-inf/lib startup projects, and the project loads the data in both directories. This is the specification of the war package. To change the classpath of the preset, there is no similar configuration found in the Tomcat configuration file, so you can achieve your classloader.

A web app that runs in Tomcat. Its classpath include the following directories:
What I know is:
%tomcat%/lib
Web-inf/lib
Web-inf/classes
Classpath in the environment variables

Summary: Classpath This is an entry point for locating resources. Classpath The priority of LIB is greater than classes;

------------------------------------------------------------------------------------------------------------ --------------------

1. Environment variables in layman's terms, environment variables are variables defined in the operating system that can be used by all applications on the operating system.
View Environment variables: command line under the SET command. The set command checks to see the sum of the user variables and system variable values. The
Path environment variable
contains an environment variable between a pair of values, representing the current value of the environment variable.
When you have more than one Java development tool on your computer, how do you know that the Java commands executed in the command-line window belong to that development kit? As long as you run Java.exe with the verbose parameter, the format is as follows: When the
Java-verbose
Java Virtual machine starts, its detailed loading process information is displayed. The purpose of the
Path environment variable is to set the path for the operating system to find and execute the program, that is, if the operating system does not find the programs and commands that we want to execute in the current directory, the operating system will look in the directory specified by the PATH environment variable, Whichever is first found. The
Path environment variable can hold multiple paths, separated by semicolons (;) between paths and paths.
"Watch Your Feet" the command to run Java code is Java XXX instead of Java xxx.class! run without the. class extension. If the source file is Xxx.java, there are multiple class definitions in the file, and many of the compiled. class files can be run directly with the Java command. Only the class that contains the main function. The parameter followed by the Java command is the class name, not the file name. Although the file name is Xxx.java, it is not seen in the form of Java XXX to run the program, the key is to see the class name.
"Classpath Environment variables" Java virtual machines to load a class, go to that directory to find?
When the Java virtual machine looks for a class, it does not look in the current directory, only the directory specified by classpath, so if we do not classpath the environment variable, we will be prompted to find the class file when compiling the Java file in the current directory. So we usually use a classpath variable. Represents the current path.
Comments in Java comments in Java are divided into three types according to different uses:
Single-line comment: Double slash before the content of the comment.
Multiline Comment: via/* int c=5;*/
Document Comment: Through/** here is the comment content */
The contents of the document comments are interpreted as formal documents of the program and can be included in a document generated by a tool such as Javadoc.

\ r means accept keyboard input, equivalent to press ENTER
\ n = line break
\ t represents a tab, which is equivalent to the table key
\b Represents the backspace key, which is equivalent to back Space.
\ ' denotes single quotation marks
\ ' means double quotation marks
\ \ represents a slash "\"

What is the classpath of Java?

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.