Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Platform Plug-in Development Environment Guide
Previous Page Home Next Page

Setting the Compilation Environment

By default, your bundles will be compiled with whichever JRE is being used to run the build and with source and target levels set to 1.3 and 1.2.

PDE build is capable of configuring the JRE used during compilation on a per bundle basis.  To take advantage of this, the first thing to do is to tell PDE build which JREs you have available.  In your build configuration build.properties file, set properties to point to each of your installed JREs.  The template build.properties provided in org.eclipse.pde.build/templates/headless-build has a list of environments commented out.  Simply uncomment the properties for which you have JREs and set the value to be the set of jars that belong on the boot classpath.  For example, setting the property:

J2SE-1.5=C:/Java/1.5/jre/lib/rt.jar;C:/Java/1.5/jre/lib/jsse.jar

will compile bundles requiring java 1.5 against rt.jar and jsse.jar.  The names of the properties should match the names of the environments that PDE Build knows about.   PDE Build will automatically set the source and target levels for each environment.  The environments that PDE builds knows and their associated source/target levels are as follows:

Environment
Source
Target
CDC-1.0/Foundation-1.0
1.3
1.1
CDC-1.1/Foundation-1.1
1.3
1.2
OSGi/Minimum-1.0
1.3
1.1
OSGi/Minimum-1.1
1.3
1.2
JRE-1.1
1.1
1.1
J2SE-1.2
1.2
1.1
J2SE-1.3
1.3
1.1
J2SE-1.4
1.3
1.2
J2SE-1.5
1.5
1.5
JavaSE-1.6
1.6
1.6
PersonalJava-1.1
1.1
1.1
PersonalJava-1.2
1.1
1.1
CDC-1.0/PersonalBasis-1.0
1.3
1.1
CDC-1.0/PersonalJava-1.0
1.3
1.1
CDC-1.1/PersonalBasis-1.1
1.3
1.2
CDC-1.1/PersonalJava-1.1
1.3
1.2

Choosing the Environment for your Bundle

There are two settings that affect the environment used to compile your bundle.  One is the manifest header Bundle-RequiredExecutionEnvironment.  This header is a list of environments on which your bundle is able to run.  Your bundle should only use methods that are in the proper subset of all the environments listed.  It is desirable to have your compilation environment match your runtime environment as closely as possible.

The second setting is the property jre.compilation.profile from your bundle's build.properties file.  The value of this property should be the prefered environment for compiling this bundle if the Bundle-RequiredExecutionEnvironment list is not adequate.

These two settings together form a list of environments, jre.compilation.profile first, then the environments from Bundle-RequiredExecutionEnvironment.  The first environment on this list that is available in your build configuration (see above section) will be used to compile your bundle.

Example:
<buildDirectory>/plugins/bundleA/
META-INF/manifest.mf: Bundle-RequiredExecutionEnvironment: CDC-1.0/Foundation-1.0, J2SE-1.3
build.properties:  jre.compilation.profile=J2SE-1.4

<buildConfiguration>/
build.properties:  J2SE-1.3=C:/Java1.3/jre/lib/rt.jar;C:/Java1.3/jre/lib/i18n.jar
J2SE-1.4=C:/Java1.4/jre/lib/rt.jar;C:/Java1.4/jre/lib/jsse.jar

In the above setup, the list of environments considered (in order) is: J2SE-1.4,  CDC-1.0/Foundation-1.0, J2SE-1.3.  The bundle can run on CDC/Foundation and J2SE-1.3, but for some reason,  it should be compiled with J2SE-1.4.  In this case, J2SE-1.4 is set in the build configuration, and comes first in the list of environments, so it is used to compile the bundle.  The source and target levels used in this case are 1.3 and 1.2.  If instead, the build configuration defined only J2SE-1.3 and not J2SE-1.4, then J2SE-1.3 would be the only environment on the list for which a JRE is available, so it would be used to compile the bundle.  In that case, the source and target levels would be 1.3 and 1.1.

Explicitly Setting Compilation values

If, for some reason, using the enviroments as outlined above does not result in the desired setup, then it is possible for a bundle to explicitly list the settings it requires.  For example, if you have a bundle that uses J2SE-1.4 with asserts, then the source and target levels would need to be 1.4, instead of the default 1.3 and 1.2.

To explicitly set the java source and target levels, the bundle should set the properties javacSource and javacTarget in it's build.properties file.  These properties will override the values derived from the environment settings.

Similarily, setting the property bootClasspath in the bundle's build.properties file will override the set of jars the bundle is compiled against.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire