The difference and mutual conversion of folder, source folder and package in eclipse

In eclipse, package, source folder, and folder are all folders, but they still have some differences:
  • Folder: It is an ordinary folder, just like the ordinary folder under Windows, but all files, jars, classes, configuration files, etc. can be stored in eclipse.
  • source folder: Chinese means source package. It has all the functions of a folder, but it also has its own characteristics, that is, the java files in the source folder will be compiled, and the compiled files will be put into the compiled file path we set. .
  • The package folder is also a special kind of folder. Its special feature is that it must exist under the source folder. The upper and lower levels are distinguished by dots, and his path finally constitutes the package path name of each class.
package and sourceFolder comparison

Similarities:
In addition to java files, other files can also be included in the package, and the compiled and packaged file paths have the same rules as the file paths under the source folder

Except for the difference:

  1. SourceFolder relies on "/" for upper and lower level division, and package relies on "." for upper and lower level division.
  2. A package can be built under the source folder, but a source folder cannot be built under the package
  3. The package attribute in the java file is assigned according to the package path. The source folder path does not participate in the assignment of the package attribute of the java file, and then it is concluded from the second difference that the package attribute of all java files under the source folder is empty.
Convert between package, source folder, folder

Convert package to folder Display: select package, build path->Exclude
folder Convert to package Display: select folder, build path->Include

Convert package to source folder Display: Select package, build path-> Use as Source folder Source folder
Convert to package Display: Select folder, build path-> Remove from BuildPath

folder to source folder display: select folder, build path -> Use as Source folder
source folder to folder display: select source folder, build path->Remove from BuildPath

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325558959&siteId=291194637