是否可以创建命令行 JDT 应用程序?
我想创建一个命令行应用程序来分析 Java 代码。 Eclipse JDT 似乎是完成这项工作的正确工具,但是我在 JDT 上找到的每个教程都将 JDT 作为 Eclipse 插件启动。
我期待这样的事情:
public static void main(String[] args) throws Exception {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
...
}
开始。但是 getWorkspace() 会抛出服务未启动的异常。
I want to create a command line application which does analysis of Java code. The Eclipse JDT seems like the right tool for the job, however every tutorial I can find on the JDT starts up the JDT as an Eclipse plugin.
I would expect something like this:
public static void main(String[] args) throws Exception {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
...
}
to get started. However getWorkspace() throws an exception that the service is not started.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你想利用 JDT,你必须启动 eclipse。您可以使用扩展点“org.eclipse.core.runtime.applications”来创建从命令行启动的最小应用程序。
我的plugin.xml 如下所示:
MANIFEST.MF:
Application1.java:
输出为:
If you want to leverage JDT you have to start eclipse. You can use the extension point "org.eclipse.core.runtime.applications" to create a minimal application that starts from the command line.
My plugin.xml looks like this:
MANIFEST.MF:
Application1.java:
Output is:
您需要确保首先启动了 Eclipse。使用 EclipseStarter 类来运行,然后您可以使用 ResourcesPlugin 上的方法。
You want to make sure you have started Eclipse first. Use the EclipseStarter class to get things running and then you can use the methods on ResourcesPlugin.