如何从 Eclipse 插件项目生成可执行的 .jar?

发布于 2024-11-08 22:02:36 字数 287 浏览 0 评论 0原文

我创建了一个 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 技术交流群。

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

发布评论

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

评论(3

写下不归期 2024-11-15 22:02:36

这个想法没有帮助,因为“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.

找个人就嫁了吧 2024-11-15 22:02:36

我不太清楚你想要完成什么。就其定义而言,插件不能单独运行。您始终需要框架才能执行它。基本上您可以做两件事:

  1. 如果您打算分发插件供其他人使用,您可以从 plugin.xmlOverview 选项卡导出插件> 编辑器。
  2. 如果您想在 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:

  1. If you intend to distribute the plug-in for others to use, you can export the plug-in from the Overview tab of the plugin.xml editor.
  2. If you want to run the plug-in on its own in an instance of the Eclipse platform, you have to create a .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.
当梦初醒 2024-11-15 22:02:36
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.2
Created-By: 1.6.0_22-b04 (Sun Microsystems Inc.)
Class-Path: 
X-COMMENT: Main-Class will be added automatically by build
Main-Class: javaapplication2.JavaApplication2

在你的jar“META-INF”中创建文件夹
命名文件 MANIFEST.MF 附加以上内容
指向你的主类文件

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.2
Created-By: 1.6.0_22-b04 (Sun Microsystems Inc.)
Class-Path: 
X-COMMENT: Main-Class will be added automatically by build
Main-Class: javaapplication2.JavaApplication2

in your jar "META-INF" create folder
name file MANIFEST.MF append above content
point your main class file

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