All classes in the java package generate class, java package class
Delimiter to change the behavior separator (this process is called class file registration ). These java files are not required to be related to each other. They can belong to different packages and be in different folders (of course, we recommend that java files with the same package path be placed under the same file path ), the javac command only reads the records in a row and performs class compilation as a unit.
Examples. Assume that your package is stored in the SRC folder, and the SRC parent directory is project. sourcelist.txt is also created in the project folder. First, register the java file you need to compile in this package with the src path (for example, src \ com \ test \ test.java.zip to the sourcelist.txt file; create a new bin folder in the project folder (or class folder, and name it as needed ), used to place the compiled class file (this configuration is understood by the-d option in the javac command); If there are other class libraries (such as jxl. jar or mysql. jar), we recommend that you create a new lib (also named but not limited) folder under the project directory, and then copy it to the folder (with the-classpath option for understanding). Finally, check that the above preparations are complete, win + R and Enter cmd. Now run the cd command in cmd to switch to the project directory, and then enter the command:
Javac-classpath lib/jxl. jar-sourcepath src @sourcelist.txt-d bin
It's easy to understand now. -D option indicates destination, that is, the generated class file is sent to the bin folder after this option;-classpath is to register the jar package you want to use into the class loading path; -sourcepath is used to tell the javac command where to find class files.
Finally, for convenience, you can create a bat file in the project folder and enter the following content:
Javac-classpath lib/jxl. jar-sourcepath src @sourcelist.txt-d bin
@ Pause
In this case, you can directly click the corresponding Java file and add or modify it in the sourcelist.txt file. This is actually a manifestation of "weak coupling" and modularization.