August 23, 2005 - Headless Hello World in Eclipse

Yesterday I needed to find out how to create a headless (console-mode, non-GUI) application plug-in for Eclipse, and while I could easily find information assuring me it could be done, I had more trouble finding out exactly how to do it. Turns out it is really easy. My "headless hello world" plug-in is here, and if you read on you'll get my pictorial guide to building your own headless hello world plug-in.

start by going to the File menu and choosing New and then Other from the select a wizard dialog choose Plug-in Project enter your project name, which will be the package for your classes turn off the checkbox for making contributions to the UI turn off the template checkbox and hit finish

when the project is created the manifest editor will open

switch to Extensions tab, hit new Extension, select org.eclipse.core.runtime.applications r-click the extension and select New -> application r-click on the application and select New -> run select the new run item then hit the underlined class* link in the attribute editor dialog select finish to create a default version of your class open then new java file in the editor enter your code for run and then save

in the manifest editor select the plugin.xml tab as you may need to correct an error about missing id fix the error by adding the id attribute with name you will use to invoke your new headless application

r-click your project and choose Export from the Export dialog choose Deployable plug-in and fragments choose your Eclipse installation directory (and optionally select the include source code checkbox)

from the command-line invoke your application with the -application flag using the value of your project name plus the extension id supplied in the plugin.xml


Posted by Jeffrey Fredrick at August 23, 2005 02:34 PM


Trackback Pings

TrackBack URL for this entry:
http://www.developertesting.com/mt/mt-tb.cgi/159

Listed below are links to weblogs that reference Headless Hello World in Eclipse:

» Headless Hello World at EclipseCon 2006? from Developer Testing
Back in August I wrote a pictorial guide to creating a headless hello world eclipse plug-in; now I've proposed to cover the same information in a short talk at EclipseCon 2006 and I've decided to use my massive blog fanbase... [Read More]

Tracked on December 1, 2005 09:44 AM

» Headless Hello World at EclipseCon 2006! from Developer Testing
Way back in August I wrote a pictorial guide to creating a headless hello world eclipse plug-in, and then in December I tapped the power of my massive blog fanbase to shill for votes for my EclipseCon short talk proposal.... [Read More]

Tracked on February 10, 2006 02:38 PM


Comments

It would be interesting to note here how long it takes to start your application with the extra overhead that Eclipse obviously contains. For example, dose it start up sub-second? Or does it take 5 seconds to do this?

Note that the answer wouldn't be important in terms of an 'Eclipse is slow' argument, just be interesting to see what the standard overhead is in getting this up and running.

Posted by: Alex Blewitt on August 24, 2005 06:09 AM

Good point, as that was one of my big questions in doing this exercise. Turns out that on my laptop the hello world does take just about exactly 5 seconds, so the overhead isn't what you'd expect.

Posted by: Jeffrey Fredrick on August 24, 2005 07:00 AM

Starting such a simple example should not take anywhere near 5 seconds. Are you deploying the plug-in to the same directory as the rest of the IDE plug-ins?

Try deploying it to just the RCP build. Or, use the product editor (File > New > Other... > Plug-in Development > Product Configuration (you'll need to use it to create a product extension, or create the file from a pre-existing product extension).
Ensure that only the RCP plug-ins are included in the Configuration tab, then click on the "Export Product export wizard" from the Exporting tab.

Posted by: Nick Edgar on September 2, 2005 06:07 AM

Good to know I could eliminate the overhead if were doing just an RCP build. It makes sense that most of that 5 seconds was loading all those other plug-ins...

Posted by: Jeffrey Fredrick [TypeKey Profile Page] on September 2, 2005 10:17 AM

"java -jar startup.jar -application org.foo.helloWorld.HelloWorld"

also works on Eclipse 3.1

Posted by: clark on September 26, 2005 05:03 AM

I had wondered if the launcher.Main was in the manifeest -- good to know that using -jar works. Was it not this way in Eclipse 3.0?

Posted by: Jeffrey Fredrick on September 26, 2005 09:19 PM

After properly executing your step I could not get the the screen output when I ran
java -jar startup.jar -application org.foo.helloWorld.HelloWorld

Specifically, when I ran it internally off the overview page to test the plugin(Launch an Eclipse Plugin) I was able to see the output. But with a no output with after running the command in at a command prompt.

Any ideas? Thanks.

Posted by: joe on October 27, 2005 09:54 PM

If I had to guess it would be that you built the plug-in eclipse but didn't deploy the plug-in -- that's the second to last step where I export the plug-in into the eclipse home directory. Only after that is the plug-in installed and runnable from the command-line.

Posted by: Jeffrey Fredrick [TypeKey Profile Page] on October 28, 2005 02:29 PM

were can I find good examples of use of plugins given:
* I want to run a headless application
* I want the headless application to use 1..n plugins I have

So I need to know how my headless application initializes and calls the plugins that I have. Where are some good examples of this? Thanks.

Posted by: Jay MacAdo on November 2, 2005 03:53 AM

@joe: I thought I had the same problem, turns out I made a typo in the "application" parameter value and Eclipse silently fails on that...

Posted by: Arnout Engelen on April 11, 2006 06:59 AM

Hi

How i run the Eclipse Rcp programe.I am using Eclipse 3.2.Plz i hope as soon as possible reple me.

With regards

Murugan

Posted by: Murugan on September 21, 2006 06:39 AM

Excellent article. I did something similar in Eclipse 3.2, however everytime I use System.out.println() command, they get written out to a NEW console window. Any idea on how to write them out to the same console used to launch the headless app?

Posted by: Ameya Barve on December 20, 2006 04:42 PM

Hi, thanks for this clear HowTo. It saved me a lot of research.
After following the steps in the howto I decided that I would like to be able to reference classes in other plugins from the headless plugin. Is this possible?
In a 'normal' plugin you can just at the dependencies to other plugins, and they are added to the plugin.xml. Howver, when I add dependecies to other plugins from the headless plugin I get a class not found exception on classes defined other plugins when running from the command line. I think this has something to do with the ogsi bundle manifest and/or the manifest in the deployed plugin. Does anybody have more information for me?
Kind regards,
Peter

Posted by: Peter on December 21, 2006 06:37 AM

Post a comment




Remember Me?