Run program.exe from eclipse plugin project(从 Eclipse 插件项目运行 program.exe)
问题描述
我正在编写一个运行 program.exe 的 eclipse 插件.我已将 program.exe 添加到插件 jar 文件中.如何执行这个程序?
I am writing an eclipse-plugin witch run program.exe. I have added program.exe to plugin jar file. How can a execute this program?
public class Handler extends AbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
Runtime.getRuntime().exec(/*What should I write here*/);
return null;
}
}
推荐答案
无法从插件jar中运行program.exe,需要解压.在您的插件中使用:
You can't run the program.exe from inside the plugin jar, so it needs to be extracted. In your plugin use:
Bundle bundle = Platform.getBundle("plugin id");
URL url = FileLocator.find(bundle, new Path("relative path to program"), null);
url = FileLocator.toFileURL(url);
这将在插件 jar 中找到程序并将其解压缩到一个临时位置(由 FileLocator.toFileURL
完成).
This will find the program in the plugin jar and extract it to a temporary location (done by FileLocator.toFileURL
).
这篇关于从 Eclipse 插件项目运行 program.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 Eclipse 插件项目运行 program.exe


基础教程推荐
- 验证是否调用了所有 getter 方法 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- Java Swing计时器未清除 2022-01-01