从eclipse插件项目运行program.exe [英] Run program.exe from eclipse plugin project
本文介绍了从eclipse插件项目运行program.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public class Handler extends AbstractHandler {
public Object execute(ExecutionEvent event)throws ExecutionException {
Runtime.getRuntime()。exec(/ *我应该在这里写什么* /);
返回null;
}
}
解决方案
你无法从插件jar中运行program.exe,因此需要解压缩。在你的插件中使用:
Bundle bundle = Platform.getBundle(plugin id);
URL url = FileLocator.find(bundle,new Path(程序的相对路径),null);
url = FileLocator.toFileURL(url);
这将在plugin jar中找到该程序并将其解压缩到临时位置(由code> FileLocator.toFileURL )。
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;
}
}
解决方案
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);
This will find the program in the plugin jar and extract it to a temporary location (done by FileLocator.toFileURL
).
这篇关于从eclipse插件项目运行program.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文