How to organize source files of Java program?

2020-02-29 11:23发布

问题:

I've created small program in Java. It uses Java classes, some images and generates some other resources (.php files, images, stylesheets etc).

I'm compiling sources as .jar and creating an .exe program, which should use my .jar and other resources.

What is the best practice to organize all sources of my Java program?

回答1:

I will recommend the below maven structure as the standard convention even if you are not using maven.

src/main/java   Application/Library sources
src/main/resources  Application/Library resources
src/main/filters    Resource filter files
src/main/assembly   Assembly descriptors
src/main/config Configuration files
src/main/scripts    Application/Library scripts
src/main/webapp Web application sources
src/test/java   Test sources
src/test/resources  Test resources
src/test/filters    Test resource filter files
src/site    Site
LICENSE.txt Project's license
NOTICE.txt  Notices and attributions required by libraries that the project depends on
README.txt  Project's readme