Eclipse执行jar中的文件
我正在开发一个 Eclipse 产品。在我的插件中,我添加了一个我需要执行的可执行文件(.exe)。当我从 Eclipse 启动产品时,使用文件系统上可执行文件的路径引用该文件,一切正常。
当我导出产品时,插件被打包在一个 jar 文件中,其中也包含可执行文件。当它引用该文件时,路径类似于:
$path_to_the_plugin_jar!/$path_to_exe_file_inside_the_jar
使用此路径启动新进程抛出异常。
我如何引用 jar 内的文件?我如何执行该文件?
用eclipse导出产品时可以解压文件吗?
谢谢
I'm developing an Eclipse product. In my plugin i have added an executable file (.exe) which i need to execute. When i launch the product from the eclipse, the file is referenced using the path of the executable on my file system and all went ok.
When i export the product the plugin is packaged in a jar file which contains the executable file too. When it references the file the path is something like :
$path_to_the_plugin_jar!/$path_to_exe_file_inside_the_jar
Using this path to launch a new Process Thrown an exception.
How can i refer to a file inside a jar?How could i execute the file?
Can i extract the file when i export the product with eclipse?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
EXE文件需要由Windows执行。出于所有实际目的,jar 文件是一个 zip 文件,因此您基本上需要弄清楚如何让 Windows 运行 ZIP 文件中的 EXE 文件。
据我所知,不存在这样的工具,因此您必须将 EXE 文件提取到临时位置,然后从那里运行它。
EXE files need to be executed by Windows. For all practical purposes a jar file is a zip-file, so you basically need to figure out how to have Windows run a EXE-file in a ZIP-file.
To my knowledge no such facility exist, so you must extract the EXE-file to a temporary location, and run it from there.
在执行之前,您可以将文件解压到捆绑状态位置。
类似的东西:
HTH Tom
Before executing you could unpack the file to the bundles-state location.
something like that:
HTH Tom
感谢您的回答。
正如 Konstantin Komissarchik 建议的那样,我通过将产品从基于插件的转换为基于功能的产品并通过在 feature.xml 文件中指定插件的“Unpack....”来解决这个问题。
当我导出产品时,插件会分解在一个文件夹中,我可以引用我需要的文件。
Thanks for your answers.
I solved, as Konstantin Komissarchik suggested, by converting the product from plugin-based to feature-based and by specify in the feature.xml file the "Unpack...." for the plugin.
When I export the product, the plugin is exploded in a folder and I can refer the files I need.