0

我想要一个项目构建路径(默认是 src...)。我可以使用一些java API吗?

4

5 回答 5

2

The question poster is writing an Eclipse plugin.

You can find the JDT API in the Eclipse help. You should be able to get the information you want from IJavaProject. See this tutorial for one example of how to get this.

于 2009-08-11T09:27:47.800 回答
2

据我所知,您可以获得如下项目路径:

String projectPath = System.getProperty("user.dir");
于 2011-08-13T22:45:17.333 回答
1

There is a set of Ant tasks for this purpose. You could, in theory, use the Ant tasks as a Java API, albeit a rather clumsy one (unless you're actually writing in Ant, that is)

于 2009-08-11T08:50:39.047 回答
0

项目默认路径只是一个常用的标准,大多数 IDE 都默认使用它,但没有可以使用的 Java API 方法。

+1

项目路径是一种开发约定,但构建的 java 应用程序独立于该开发路径。

大多数 Java IDE 允许您更改此路径。

例如,在 Eclipse 中,可以通过以下方式更改此路径:右键单击项目文件夹 > 属性 > Java 构建路径

如果您需要在外部程序中使用此路径进行构建,Eclipse 有可以使用的内部变量(用于 Ant、Maven 等)。配置“外部工具”时,例如可以使用 {$project_loc}。这将被项目路径动态替换。

于 2009-08-11T09:25:06.560 回答
0

The project default path is just a common used standard, most IDE's default to it but there are no Java API methods you can use.

于 2009-08-11T08:50:26.940 回答