Difference between revisions of "FAQ What is the classpath of a plug-in?"

From Eclipsepedia

Jump to: navigation, search
 
(See Also:)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Developers coming from a more traditional Java programming environment are
+
Developers coming from a more traditional Java programming environment are often confused by classpath issues in Eclipse.  A typical Java application has a global namespace made up of the contents of the JARs on a single universal classpath.  This classpath is typically specified either with a command line argument to the VM or by an operating system environment variable.  In Eclipse, each plug-in has its own unique classpath.  This classpath contains the following, in lookup order:
often confused by classpath issues in Eclipse.  A typical Java application has a global namespace
+
made up of the contents of the JARs on a single universal classpath.  This classpath
+
is typically specified either with a command line argument to the VM or by an
+
operating system environment variable.  In Eclipse, each plug-in has its own unique
+
classpath.  This classpath contains the following, in lookup order:
+
  
 +
*<i>The OSGi parent class loader</i>.  All class loaders in OSGi have a common parent class loader. By default, this is set to be the Java boot class loader. The boot loader typically only knows  about <tt>rt.jar</tt>, but the boot classpath can be augmented  with a command line argument to the VM.
  
* <i>The OSGi parent class loader</i>.  All class loaders in OSGi
+
*<i>The exported libraries of all imported plug-ins</i>.   If imported plug-ins export their imports, you get access to their exported libraries, too.  Plug-in libraries, imports, and exports are all specified in the <tt>plugin.xml</tt> file.  
have a common parent class loader. By default, this is set to be
+
the Java boot class loader. The boot loader typically only knows
+
about <tt>rt.jar</tt>, but the boot classpath can be augmented
+
with a command line argument to the VM.
+
</li>
+
 
+
 
+
 
+
 
+
 
+
* <i>The exported libraries of all imported plug-ins</i>.
+
If imported plug-ins export their imports,
+
you get access to their exported libraries, too.  Plug-in libraries, imports, and exports
+
are all specified in the <tt>plugin.xml</tt> file. </li>
+
 
+
 
+
 
+
 
+
 
+
* <i>The declared libraries of the plug-in and all its fragments</i>.
+
Libraries are searched in the order they are specified in the manifest.
+
Fragment libraries are added to the end of the classpath in an unspecified order.</li>
+
 
+
In Eclipse 2.1, the libraries from the <tt>org.eclipse.core.boot</tt> and
+
<tt>org.eclipse.core.runtime</tt> were also automatically added to every
+
plug-in&#146;s classpath.  This is not true in 3.0; you now need to declare the
+
runtime plug-in in your manifest&#146;s <tt>requires</tt> section, as with
+
any other plug-in.
+
 
+
  
 +
*<i>The declared libraries of the plug-in and all its fragments</i>.  Libraries are searched in the order they are specified in the manifest.  Fragment libraries are added to the end of the classpath in an unspecified order.
  
 +
In Eclipse 2.1, the libraries from the <tt>org.eclipse.core.boot</tt> and  <tt>org.eclipse.core.runtime</tt> were also automatically added to every plug-in&#146;s classpath.  This is not true in 3.0; you now need to declare the runtime plug-in in your manifest&#146;s <tt>requires</tt> section, as with any other plug-in.
  
  
  
 
== See Also: ==
 
== See Also: ==
 +
*[[FAQ What is the plug-in manifest file (plugin.xml)?]]
 +
*[[FAQ How do I make my plug-in connect to other plug-ins?]]
 +
*[[FAQ How do I add a library to the classpath of a plug-in?]]
 +
*[[FAQ How can I share a JAR among various plug-ins?]]
 +
*[[FAQ How do I use the context class loader in Eclipse?]]
 +
*[[Pragmatic Advice on PDE Classpath]]
  
 
+
{{Template:FAQ_Tagline}}
[[FAQ_What_is_the_plug-in_manifest_file_%28%3Ctt%3Eplugin.xml%3C%2Ftt%3E%29%3F]]
+
 
+
 
+
[[FAQ_How_do_I_make_my_plug-in_connect_to_other_plug-ins%3F]]
+
 
+
 
+
[[FAQ_How_do_I_add_a_library_to_the_classpath_of_a_plug-in%3F]]
+
 
+
 
+
[[FAQ_How_can_I_share_a_JAR_among_various_plug-ins%3F]]
+
 
+
 
+
[[FAQ_How_do_I_use_the_context_class_loader_in_Eclipse%3F]]
+
 
+
<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>
+

Latest revision as of 02:26, 30 January 2007

Developers coming from a more traditional Java programming environment are often confused by classpath issues in Eclipse. A typical Java application has a global namespace made up of the contents of the JARs on a single universal classpath. This classpath is typically specified either with a command line argument to the VM or by an operating system environment variable. In Eclipse, each plug-in has its own unique classpath. This classpath contains the following, in lookup order:

  • The OSGi parent class loader. All class loaders in OSGi have a common parent class loader. By default, this is set to be the Java boot class loader. The boot loader typically only knows about rt.jar, but the boot classpath can be augmented with a command line argument to the VM.
  • The exported libraries of all imported plug-ins. If imported plug-ins export their imports, you get access to their exported libraries, too. Plug-in libraries, imports, and exports are all specified in the plugin.xml file.
  • The declared libraries of the plug-in and all its fragments. Libraries are searched in the order they are specified in the manifest. Fragment libraries are added to the end of the classpath in an unspecified order.

In Eclipse 2.1, the libraries from the org.eclipse.core.boot and org.eclipse.core.runtime were also automatically added to every plug-in’s classpath. This is not true in 3.0; you now need to declare the runtime plug-in in your manifest’s requires section, as with any other plug-in.


[edit] See Also:


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.