All classes of Java packages generate class

Source: Internet
Author: User

Javac's compilation unit is actually a single Java file, in order to achieve the purpose of compiling multiple Java files at the same time, you can save the desired compiled Java file path in a txt, such as sourcelist.txt, in order to change the behavior delimiter (this process is called Class file registration). These Java files are not necessarily related to each other, they can be subordinate to different packages, under different folders (of course, it is recommended that the package path of the same Java class file in the same file path), the Javac command will only read the records in one line, as a unit to compile the class.
An example is described. Assuming that your package is placed under the SRC folder, the parent directory of SRC is project,sourcelist.txt also created in advance under the project folder. Start with the path to the Java file in this package that you need to compile in relation to SRC (for example, src\com\test\ Test.java) Register to the Sourcelist.txt file, then create a new Bin folder in the project folder (or the class folder, named as you Like it), for the placement of the compiled class file (this with the-D option in the Javac command); If there are other class libraries (such as Jxl.jar or Mysql.jar), it is recommended to create a new Lib (also named unlimited) folder under the project directory, and then copy it to the folder (with the-classpath option); Finally check that the above preparations are complete, win + R, Do not use the input cmd, now switch to the project directory with the CD command in CMD, and then enter the command:
Javac-classpath lib/jxl.jar-sourcepath src @sourcelist. txt-d bin
Now it's a good idea. The-d option is destination meaning that the generated class file is sent to the Bin folder after the option, and-classpath is to register the jar package you want to use in the class loading path;-sourcepath is telling the Javac command where to find the class file.
Finally, for convenience, you can create a new bat file under the project folder and enter the following:
Javac-classpath lib/jxl.jar-sourcepath src @sourcelist. txt-d bin
@pause
So each time you click directly, and you need to compile other packages or other Java files, directly in the Sourcelist.txt file to add or modify. This is in fact a "weak coupling", modular performance.

All classes of Java packages generate class

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.