javac compiler

1. The basic format

the javac [target path] [source]

I.e., the target path storage position to compile the results, the following detailed explanation. Compared with the original source files needed to compile, including the * .java and jar package.

2. target path

After the target path for the compiled * .class file location.

2.1 default entry

Target path may be omitted. If omitted then placed in the current position. (Provided that run cmd in the current directory).

javac Test.java

2.2 specified path

Specify the required path parameters -d, several forms as follows:

2.2.1 full path

javac -d E:\javactest\ Test.java

The resulting file in E: \ javactest \ under.

2.2.2 relative path

(A) generate files in the current directory, if Test.java if there is a package name, then in subfolders.

javac -d . Test.java 

(Ii) generate files in the current directory classes, if Test.java if there is the package name, the next sub-file.

javac -d ./classes Test.java

(C) generate files in the current directory classes, if Test.java if there is the package name, the next sub-file.

javac -d classes Test.java

3. Source File

Source files include your files and * .java jar package. Individual files directly put the file name.

3.1 No third-party libraries

Added directly without third-party libraries, files between different sources separated by a space, the path to the file containing spaces require double quotes.

3.1.1 The basic method

javac -d ./classes Test.java Test01.java

3.1.2 Add Directory

In addition to adding Test.java Test01.java two files, but also need to present all * .java to compile the src directory.

javac -d classes Test.java Test01.java src/*.java

3.1.3 Adding a large number of files

 

When the presence of all the large number of files can be placed in the file location of a document and use the file @ added. File format as shown in FIG.

Here Insert Picture Description
The following command will Test.java filelist.txt shown and all files are packaged.

javac -d classes Test.java @filelist.txt

3.2 Adding third-party libraries

-classpath -cp by adding the latter.

3.2.1 The basic method

javac -d classes -classpath XXXX.jar @filelist.text

3.2.2 Adding Multiple Files

Add multiple files with a semicolon

javac -d classes ;XXXX.jar;d:\XXX\*.jar @filelist.text

4. Generate jar package

Can be generated by jar command packet, i.e. classes \ class \ ii under com \ LL01 packaged into test.jar

jar cf test.jar classes\com\ii\LL01

Guess you like

Origin www.cnblogs.com/llstart-new0201/p/11781475.html