Refer to link 1: get out of the IDE and see how javac compiles
Include all jars in the directory in the Java classpath
Overview of engineering structure
The current engineering structure is as follows:
PS D: ye Jiancheng, Java, primary, test_ Jsoup - replica > tree / F
Folder path list of volume data
The volume serial number is f0a7-7514
D:.
│ .project
│
├─bin
├─lib
│ jsoup-1.11.3.jar
│
└─src
├─demo
│ Demo.java
│ fuck_xyr.java
│
└─test
Current location:
PS D: ye Jiancheng, Java, primary, test_ Jsoup - replica > dir
Directory: D: ye Jiancheng, Java, primary, test_ Jsoup - Replica
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2020/7/15 15:03 bin
d----- 2020/7/15 14:33 lib
d----- 2020/7/15 14:33 src
-a---- 2020/7/15 14:37 214 .project
It was originally an ecplise project directory, which was deleted in a mess.
Simple test fuck_ Xyr
compile
Compile command
javac
PS D: ye Jiancheng, Java, primary, test_ Jsoup - replica > javac
Usage: javac < Options > < source files >
Among them, the possible options include:
@< filename > read options and filenames from files
-Akey [= value] options passed to comment handler
--Add modules < modules > (, < modules >)*
In addition to the original module, if the
All-module-path, all modules in the module path.
--boot-class-path <path>, -bootclasspath <path>
Override the location of the bootstrap class file
--class-path <path>, -classpath <path>, -cp <path>
Specifies where to find user class files and comment handlers
-D < Directory > specifies the location of the generated class file
-Depredation outputs the source location using the obsolete API
--Enable preview enables the preview language feature. To be used with - source or -- release.
-Encoding < encoding > specifies the character encoding used by the source file
-Endorseddirs < dirs > override the location of the signature's standard path
-Extdirs < dirs > covers the location of the installed extensions
-G generate all debugging information
-g: {lines, vars, source} only generates some debugging information
-g: None does not generate any debugging information
-H < Directory > specifies the location to place the generated native header file
--Help, - help, -? Output this help message
--Help extra, - x outputs help for additional options
-Implicit: {none, class} specifies whether to generate class files for implicit reference files
-J < flag > directly passes the < flag > to the runtime system
--Limit modules < modules > (, < modules >)*
Limit the scope of observable modules
--Module < module > (, < module > *) - M < module > (, < module >)*
Only the specified module is compiled, please check the timestamp
--module-path <path>, -p <path>
Specifies where to find application modules
--module-source-path <module-source-path>
Specifies where to find input source files for multiple modules
--Module version < version > specifies the version of the module being compiled
-Nowarn does not generate any warnings
-Parameters generates metadata for reflection of method parameters
-Proc: {none, only} controls whether annotation processing and / or compilation is performed.
-processor <class1>[,<class2>,<class3>...]
The name of the comment handler to run; bypasses the default search process
--processor-module-path <path>
Specifies the module path to find the comment handler
--processor-path <path>, -processorpath <path>
Specifies where to find the comment handler
-Profile < profile > make sure that the API you are using is available in the specified configuration file
--Release < release > compiles for the specified Java se distribution. Supported distributions: 7, 8, 9, 10, 11, 12, 13
-S < Directory > specifies the location of the generated source file
--source <release>, -source <release>
Provides source compatibility with the specified Java se distribution. Supported distributions: 7, 8, 9, 10, 11, 12, 13
--source-path <path>, -sourcepath <path>
Specifies where to find the input source file
--System < JDK > | none covers system module location
--target <release>, -target <release>
Generates a class file suitable for the specified Java se distribution. Supported distributions: 7, 8, 9, 10, 11, 12, 13
--upgrade-module-path <path>
Override upgradeable module location
-Hibernate outputs messages about what the compiler is doing
--Version, - version version information
-Abort compilation on warning from werror
Compile current project
target: compile the fuck in the. / SRC / demo directory_ xyr.java , and will compile the_ xyr.class File output to the. / bin / demo folder (as ecplise does)
fuck_ xyr.java The contents of the document are as follows:
package demo;
public class fuck_xyr {
public static void main(String[] args) {
// TODO Auto-generated method stub
String url = "https://jingyan.baidu.com/article/bad08e1e23982609c851219e.html";
System.out.println(url);
}
}
Compile command:javac .\src\demo\fuck_xyr.java -d ./bin
The compiled project structure is as follows:
PS D: ye Jiancheng, Java, primary, test_ Jsoup - copy > javac. ﹥ SRC ﹣ demo ﹣ fuck_ xyr.java -d ./bin/demo
PS D: ye Jiancheng, Java, primary, test_ Jsoup - replica > tree / F
Folder path list of volume data
The volume serial number is f0a7-7514
D:.
│ .project
│
├─bin
│ └─demo
│ fuck_xyr.class
│
├─lib
│ jsoup-1.11.3.jar
│
└─src
├─demo
│ Demo.java
│ fuck_xyr.java
│
└─test
You can find that there is a fuck in the. / bin / demo directory_ xyr.class
function
PS D: ye Jiancheng, Java, primary, test_ Jsoup - replica > java - classpath "." / bin " demo.fuck_ Xyr
https://jingyan.baidu.com/article/bad08e1e23982609c851219e.html
Introducing other jar packages
How to reference jar package in Java and add compilation run?
How to call jar package?
How to compile and run jar package?
These may be your concerns. The following steps let you fully understand the compilation and running parameters of Java
compile
Compile current project
target: compile the fuck in the. / SRC / demo directory_ xyr.java , and will compile the_ xyr.class File output to the. / bin / demo folder (as ecplise does)
fuck_ xyr.java The contents of the document are as follows:
package demo;
import java.io.IOException;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
public class Demo {
public Demo() {
// TODO Auto-generated constructor stub
}
// throws IOException
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
String url = "https://jingyan.baidu.com/article/bad08e1e23982609c851219e.html";
Connection connection = Jsoup.connect(url);
Document document = connection.get();
System.out.println(document.html());
}
}
A very simple operation of calling jar to request web page
Compile command:javac .\src\demo\Demo.java -d ./bin -classpath "./lib/jsoup-1.11.3.jar"
The compiled project structure is as follows:
PS D: ye Jiancheng, Java, primary, test_ Jsoup - replica > tree / F
Folder path list of volume data
The volume serial number is f0a7-7514
D:.
│ .project
│
├─bin
│ └─demo
│ Demo.class
│ fuck_xyr.class
│
├─lib
│ jsoup-1.11.3.jar
│
└─src
├─demo
│ Demo.java
│ fuck_xyr.java
│
└─test
It is found that there is one more in. / bin / demo Demo.class
function
Run command:java -classpath "./bin;./lib/jsoup-1.11.3.jar" demo.Demo