【问题标题】:How to organize source files of Java program?如何组织Java程序的源文件?
【发布时间】:2012-08-09 05:05:11
【问题描述】:

我在Java 中创建了小程序。它使用 Java 类、一些图像并生成一些其他资源(.php 文件、图像、样式表等)。

我正在将源代码编译为 .jar 并创建一个 .exe 程序,它应该使用我的 .jar 和其他资源。

组织我的 Java 程序的所有源的最佳做法是什么?

【问题讨论】:

  • 组织你的 java 类的一种常用方法是将它们分布在包之间(按照你想要的层次结构),同时你可以创建单独的文件夹(图像、css、脚本)来保存你的图像和其他东西.

标签: java resources jar exe project-organization


【解决方案1】:

即使您不使用 maven,我也会推荐以下 maven 结构作为 standard convention

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

【讨论】:

  • +1 我发誓我也在考虑 maven :D,很高兴看到你的回答。
  • 我正在使用 Maven,所以您的回答非常适合我。谢谢!
  • 但我不明白src/site 是干什么用的。静态网站模板?
  • 看这里maven.apache.org/guides/mini/guide-site.html 了解“站点”中的内容
猜你喜欢
  • 1970-01-01
  • 2010-11-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多