Eclipse Kepler: how to export RCP product as an executable jar - eclipse

I just started using Eclipse Kepler. From the Overview tab I'm able to select 'Eclipse Product export wizard' which generates an executable (.exe) that can be executed from the command line.
How can I export the product as an executable .jar that can be executed from the command line?

Eclipse RCPs are always executable .exe files (or the equivalent on other platforms), there is no option to create a Jar file.
Eclipse code contains platform specific components so you have to do a different build for each platform.
If you want to generate code to run on Linux, Mac OS X or the other supported platforms you need to check the Export for multiple platforms option on the product export page and select the platforms on the next page of the wizard.
You will need to install the RCP Delta Pack to build for multiple platforms.
Update: The Export wizard is now deprecated. tycho and maven is now the recommened way to build RCPs.
See Eclipse Products and Deployment for more details.

While there is no option to export your product as an executable .jar, you can start your application without using the executable (.exe). All the executable does is show the splash screen, load a JVM and start the Equinox launcher which is an executable .jar.
You can start the Equinox launcher from the command line yourself with the command java -jar plugin\org.eclipse.equinox.launcher_<version>.jar which will start the application (without the splash screen of course).
The Eclipse wiki has launcher scripts that make it easier to deal with the version part of the plugin name.
This will however not make the application launch on other platforms as it still contains platform specific plugins. See greg-449's answer on how to export for multiple platforms if that's what you want to do.

Related

Running plugins without opening Eclipse IDE

Using Eclipse IDE we have created plugin which is used to open the Directory Dialog on selection of the option openDialog in menu bar which performs the operation of reading the file names inside the directory and then creates a new file and pops up the Save Dialog in which we can specify the desired location to save the created file. So to run this plugin we need Eclipse IDE to be opened.
Question 1: Can we run that plugin without opening the Eclipse IDE.
Question 2: I want to export this plugin in the form of .exe or jar such that when I run that .exe in the windows we want to start executing that plugin.
Finally we want to run the plugins as Standalone application without opening the eclipse IDE
Thanks in Advance
No you can't run a plug-in on its own, it will depend on many other plug-ins and the Eclipse/OSGi framework.
You may be able to write an Eclipse Rich Client Program (RCP) standalone application containing the plug-in and the other required plug-ins.

Launching Eclipse plug in template

I created a Eclipse plug-in project by selecting a plug-in template provides by the eclipse. Then i ran the plug-in it opened another eclipse and the plug-in executed there.Why so? is the plugin taking eclipse's application class to create workbench?
As an elaboration of "If you want to run the plugin in your main workspace you will have to export the plugin and install it in your main Eclipse." that #greg-449 had in his answer. You can do this.
Step 1 - Export your plugin
From the File menu, choose Export... and then choose the Deployable plug-ins and fragments wizard.
Step 2 - Configure your Wizard Options
Select the plug-ins you want to export.
As the destination, choose Install into host
Press Finish
Step 3 - Confirm unsigned content
As you are probably not signing your plug-in, but you do trust it, say Yes to the Warning: you are installing software that contains unsigned content.
Step 4 - Restart Eclipse
Restart Eclipse when prompted to to enable the plug-ins.
Result
You should now see your new plug-ins. To make this example I used the new Plug-in wizard and choose the "Hello, World Command" template. The arrows below point to the contributions in the UI that the plug-in made.
When you run a plugin (Run As > Eclipse Application) Eclipse starts a new instance of Eclipse including your plugin and uses a new workspace. This enables you to test the plugin without damaging your main Eclipse installation and workspace.
If you want to run the plugin in your main workspace you will have to export the plugin and install it in your main Eclipse.
If you want to run your plugin as part of an RCP you can set the application or product launched in the 'Run > Run Configurations...' entry.
For example:
Here I am running a product called 'greg.music.e4.rcp.product'

How to build and install an Eclipse plugin using ant

How do I build and install an Eclipse plugin using ant? I want to build a plugin as a zip file and then install the plugin on 32bit or 64bit eclipse. What am I supposed to do here?
Indeed, using PDE/Build to achieve a so-called headless build is difficult, but not impossible.
We are still building our RCP this way.
I recommend reading Paulin's and Sharma's tutorials on the issue.
The Eclipse PDE has its own builder which is built on ant. I'm not sure from your question if you are looking to simply build/export your plugin within eclipse or generate ant build scripts that can be run outside of eclipse. The latter is more difficult. Inside eclipse you can simple go to file -> export -> Plugin-Development -> Deployable plugin and the export wizard will walk you through it, you can select to deploy a zip or exploded directory and then select output location and presto you have your plugin built as a jar that can be dropped into an eclipse instance. If you are looking to use ant outside of eclipse to build you need to go through a series of steps that are complicated to get a 'headless build", if this is what you need to do Google "pde headless" build. I've tried it but gave up. There is also a good book "Building highly modular systems with OSGI/Equinox that has a chapter devoted to this. - Duncan

Does Eclipse ship ant with its own distribution?

First time using Apache Ant (I'm excited and overwhelmed at the same time!) for automating a Java app.
I did not go to the ant website and download ant directly. Rather, I'm using the standard plugin that ships with Eclipse. From Eclipse, I can run test build.xml projects perfectly. But when I go to run ant directly off the command-line, Windows doesn't recognize it as a recognized command.
This leads me to believe that I either do not have ant installed, or I have not configured it properly (at all). If it's not installed, then why do these build.xml scripts work when I fire them inside of Eclipse? Does Eclipse ship with its own distrib of ant that isn't accessible from the cmd line?
And if it's just a config issue, what do I need to do in order to get ant to run a buildscript of my own flavor?
I want to start using Apache Ivy and in order to run the demos I first need ant up and running from the command line.
Thanks for any help or insight :-)
Does Eclipse ship with its own distrib of ant that isn't accessible from the cmd line?
Essentially, yes. Eclipse bundles the core Ant runtime plus its own extensions and integration, but it's private to the Eclipse installation.
If you want to run the builds from outside of Eclipse, you need to download and install the full distribution of Ant.

Getting a RCP feature to export to a p2 site that supports multiple platforms using Buckminster

I have a simple RCP Plugin (with a product) and I want it to run in atleast Linux and Windows (32 and 64bit). I have a product that contains a Feature from which buckminster uses to create the p2.site. (I only use a build.properties and buckminster.properties files, no *.cspec and *.rmap files, since these probably get generated by buckminster from the RCP product/feature files).
My problem is that my feature has a link to the 64bit linux swt plugin (I'm running 64bit linux) but if I add references to the windows swt plugins to my RCP .product the buckminster build fails to resolve these plugins and then does not export the p2.site correctly.
How do I get buckminster to build the p2 site by looking at the dependencies of my RCP .product file and if it doesn't resolve the win32 or win64 swt libraries from my workspace that it will look else where for these dependencies?
I like the idea of buckminster determining my project dependencies from my .product file so I don't have to keep a .cspec and a .product file in sync, when I make changes to my project's dependencies. If the dependencies are not found on my workspace then I want buckminster to find the missing dependencies (could be all of them if running from Hudson server) from "maybe" a .rmap etc
You have to execute your site.p2 target several times, to provide a build for each platform.
See the tutorial on the Eclipse wiki or on Ralf Ebert's blog about more specific details.