Jump to: navigation, search

Difference between revisions of "FAQ How do I create an application?"

 
m
 
Line 1: Line 1:
To create an application, you need a plug-in that adds an extension to the
+
To create an application, you need a plug-in that adds an extension to the <tt>org.eclipse.core.runtime.applications</tt> extension point.  An example application definition from a <tt>plugin.xml</tt> file is as follows:
<tt>org.eclipse.core.runtime.applications</tt> extension point.  An example  
+
application definition from a <tt>plugin.xml</tt> file is as follows:
+
 
<pre>
 
<pre>
   &lt;extension  
+
   &lt;extension id=&quot;helloworld&quot; point=&quot;org.eclipse.core.runtime.applications&quot;&gt;
      id=&quot;helloworld&quot;
+
      point=&quot;org.eclipse.core.runtime.applications&quot;&gt;
+
 
       &lt;application&gt;
 
       &lt;application&gt;
 
         &lt;run class=&quot;org.eclipse.faq.HelloWorld&quot;/&gt;
 
         &lt;run class=&quot;org.eclipse.faq.HelloWorld&quot;/&gt;
Line 13: Line 9:
  
  
The <tt>class</tt> attribute of the <tt>run</tt> element must specify
+
The <tt>class</tt> attribute of the <tt>run</tt> element must specify a class that implements <tt>org.eclipse.core.boot.IPlatformRunnable</tt>. Here is the source of a trivial application:
a class that implements <tt>org.eclipse.core.boot.IPlatformRunnable</tt>.
+
Here is the source of a trivial application:
+
 
<pre>
 
<pre>
 
   public class HelloWorld implements IPlatformRunnable {
 
   public class HelloWorld implements IPlatformRunnable {
Line 25: Line 19:
 
</pre>
 
</pre>
  
To run the application, you need to specify the fully qualified ID of  
+
To run the application, you need to specify the fully qualified ID of your application extension definition, using  the <tt>application</tt> command-line argument when launching Eclipse:
your application extension definition, using  the <tt>application</tt>  
+
command-line argument when launching Eclipse:
+
 
<pre>
 
<pre>
 
   eclipse -application org.eclipse.faq.helloworld.helloworld
 
   eclipse -application org.eclipse.faq.helloworld.helloworld
 
</pre>
 
</pre>
The fully qualified extension ID is computed by prepending the  
+
The fully qualified extension ID is computed by prepending the plug-in ID to the simple extension ID from the <tt>plugin.xml</tt> file. In this example, the plug-in ID is <tt>org.eclipse.faq.helloworld</tt>, and the simple extension ID is <tt>helloworld</tt>.
plug-in ID to the simple extension ID from the <tt>plugin.xml</tt> file.
+
In this example, the plug-in ID is <tt>org.eclipse.faq.helloworld</tt>, and
+
the simple extension ID is <tt>helloworld</tt>.
+
  
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>
+
{{Template:FAQ_Tagline}}

Latest revision as of 20:20, 19 June 2006

To create an application, you need a plug-in that adds an extension to the org.eclipse.core.runtime.applications extension point. An example application definition from a plugin.xml file is as follows:

   <extension id="helloworld" point="org.eclipse.core.runtime.applications">
      <application>
         <run class="org.eclipse.faq.HelloWorld"/>
      </application>
   </extension>


The class attribute of the run element must specify a class that implements org.eclipse.core.boot.IPlatformRunnable. Here is the source of a trivial application:

   public class HelloWorld implements IPlatformRunnable {
      public Object run(Object args) throws Exception {
         System.out.println("Hello from Eclipse application");
         return EXIT_OK;
      }
   }

To run the application, you need to specify the fully qualified ID of your application extension definition, using the application command-line argument when launching Eclipse:

   eclipse -application org.eclipse.faq.helloworld.helloworld

The fully qualified extension ID is computed by prepending the plug-in ID to the simple extension ID from the plugin.xml file. In this example, the plug-in ID is org.eclipse.faq.helloworld, and the simple extension ID is helloworld.


This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.