如何从 Eclipse 插件项目生成可执行的 .jar?
我创建了一个 Eclipse 插件项目,该项目可以正确运行并且可以部署到 Windows exe 中。但是,我需要能够在其他平台上运行此应用程序,因此我想生成该应用程序的可执行 .jar 文件。问题是我到处搜索,所有执行此操作的方法都需要一个包含要提供的主要方法的“Main”类。因为我的项目是一个插件项目,所以它使用 eclipse 生成的“Application”类来启动应用程序,因此不包含可以引用的“Main”类。如果我忽略引用它,则会生成一个 jar,但它不会运行,因为它收到“无法加载主类清单属性”错误。有没有办法绕过引用主类来创建可执行 jar?
I have created an eclipse plug-in project that runs correctly and that can be deployed to a windows exe. However I need to be able to run this application on other platforms, so I would like to generate an executable .jar file of the application. The problem is that I have searched everywhere and all the methods of doing this require a "Main" class that contains a main method to be provided. Because my project is a plug-in project it makes use of an "Application" class that is generated by eclipse to kick start the application, and therefore does not contain a "Main" class that can be referenced. If i neglect to reference it a jar gets generated, but it won't run because it gets the "Failed to load Main-class manifest attribute" error.Is there a way to get around referencing a main class to create an executable jar?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个想法没有帮助,因为“eclipse.exe”不是您的发行版中唯一依赖于操作系统的文件:SWT 库也不能在其他平台上使用。
使用 Eclipse,您必须在 Eclipse 中为不同平台构建应用程序。
The idea doesn't help, because the "eclipse.exe" is not the only OS-dependent file in your distribution: the SWT libraries can't be used on other platforms too.
With eclipse you'll have to build your application for different platforms from within eclipse.
我不太清楚你想要完成什么。就其定义而言,插件不能单独运行。您始终需要框架才能执行它。基本上您可以做两件事:
.product
文件来描述您的应用程序需要哪些插件及其名称,启动画面等。Eclipse 有一个编辑器可以帮助您设置该文件。这将创建一个特定于平台的启动器,您可以使用它轻松地在所需平台上运行应用程序。根据您的目标平台,您可能需要安装增量包。It's not exactly clear to me what you want to accomplish. A plug-in by its very definition can't run on it's own. You always need the framework in order to execute it. Basically you can do two things:
.product
file that describes which plug-ins your application needs, what its name is, splashscreen etc. Eclipse has an editor that helps you setting up that file. This creates a platform specific launcher with which you can easily run the application on the desired platform. Depending on your target platform you might need to install a delta pack.在你的jar“META-INF”中创建文件夹
命名文件
MANIFEST.MF
附加以上内容指向你的主类文件
in your jar "META-INF" create folder
name file
MANIFEST.MF
append above contentpoint your main class file