简体   繁体   中英

How to generate an executable .jar from an Eclipse plug-in project?

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?

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 .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM