And the use of Java annotations in CLASS_PATH

A, CLASS_PATH use

When we installed the jdk, usually only in the new environment variable in a computer system variable JAVA_HOME, this variable is used before storing the jdk / bin folder path, and then use the system variables in the path,% JAVA_HOME% \ bin, thus configured, the general this time we can write properly and run the java program;

This time for us to look at CLASS_PATH, why do not we start with CLASS_PATH, the program can compile and run properly, because CLASS_PATH has a default value, that is, ".", That is, the current directory.

As shown below, Hello.java create a file in the specified folder, and then the program is compiled using javac command, corresponding to the generated class files, and then use the java command interpreter running the program under the current directory

 

 If you then change to another directory, it will execute the command java Hello error

 

If jdk9, then, will be reported error classnotfound, resulting in errors is because of this reason: When you execute the command java Hello, jvm will you execute the command to the current folder, find the name of the Hello bytecode files and load, because not found, it will be an error, because the default value CLASS_PATH is the current path, if you do not want an error, then create a new CLASS_PATH in the system environment variables, its value is set to store java bytecode program path to the file, the configuration is complete, turn off its command line, open again, execute the command java Hello matter in which path are not being given, you can correct the output; although this can run properly, but we do not recommended, because once you set the value of CLASS_PATH, all you need to bytecode files into the specified path, it will cause a lot of trouble in your development process, it is recommended not to change the CLASS_PATH value, let it use the default values ​​can be removed from the development process unnecessary trouble.

 Second, the use of annotations

In the team development process, add comments in the code is very necessary, add comments will make your code with a high readability, for team development, it is very necessary.

Notes divided into three types: single-line comments, multi-line comments and documentation comments,

Single-line comments: with "//" indicates, generally with a single line of code comments and description

Multi-line comments: represented by "/ * .... * /", and the general description of the method for annotating

Document Note: represented by "/ * ... * /" is generally used to illustrate the method of the annotation or class

Note: java compilation, annotations are not compiled into, it will not affect the program.

Guess you like

Origin www.cnblogs.com/li666/p/11797546.html