1

这里是Java新手。我在 IntelliJ IDEA 11.1 中创建了一个小型桌面应用程序。它由几个带有类的 java 文件和主应用程序文件 Main.java 组成。我想制作另一个应用程序,它使用相同的类但不同的主文件。我希望能够更改两个项目的类源代码。因此,我希望有一个类似的结构:

IdeaProjects\lib/myclasses\*.java (or similar with additional src if recommended)
IdeaProjects\project1\src\Main.java
IdeaProjects\project2\src\Main.java

我该如何正确地做到这一点?我已经阅读了很多关于模块、库、罐子的内容,但现在我迷路了:(

4

1 回答 1

1

I don't use IntelliJ so I can not help you specifically but You should create one project containing the shared resources and per program another project containing you Main files. Compile this first project into a jar file so you can use it as a library in the projects containing the main files.

In eclipse You can add other projects to your classPath. Maybe this is also possible in IntellyJ.

于 2012-11-20T18:45:05.297 回答