Eclipse执行jar中的文件

发布于 2024-10-22 05:30:23 字数 343 浏览 1 评论 0原文

我正在开发一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

手心的温暖 2024-10-29 05:30:23

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.

暮倦 2024-10-29 05:30:23

在执行之前,您可以将文件解压到捆绑状态位置。
类似的东西:

InputStream stream = FileLoactor.openStream(myBundle, new Path("path/to/exe/")
IPath pathUnpacked = myBundle.getStateLocation().append("myExe.exe");
writeToDisk(stream, pathUnpacked);
Program.launch(pathUnpacked.toOSString());

HTH Tom

Before executing you could unpack the file to the bundles-state location.
something like that:

InputStream stream = FileLoactor.openStream(myBundle, new Path("path/to/exe/")
IPath pathUnpacked = myBundle.getStateLocation().append("myExe.exe");
writeToDisk(stream, pathUnpacked);
Program.launch(pathUnpacked.toOSString());

HTH Tom

风吹雨成花 2024-10-29 05:30:23

感谢您的回答。

正如 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文