I'd like to replace some of the classes (javax.tools.*
) of rt.jar
that my Eclipse plug-in depends on by my own versions of these classes. Replacing the classes in rt.jar
is typically done by setting the bootclasspath. My question is how to do this in an Eclipse plug-in.
I created a JAR file of my versions of these classes and added it to the Bundle-ClassPath
attribute of MANIFEST.MF
, the bin.includes
attribute of build.properties
, and .classpath
. I also entered the path to my JAR file to the field called "Bootstrap entries:" of the Eclipse Application launch configuration dialog and moved my JAR to the top in the "Order and Export" tab at "Project Properties > Build Path". Nonetheless, when I run my Eclipse plug-in using an Eclipse Application launch configuration, the plug-in uses the original classes in rt.jar
rather than the ones in my JAR file.
How can I configure my Eclipse plug-in so that it first looks up the classes in my JAR file and consults rt.jar
only if the class is not found in my JAR file?
The solution that I found is to configure the JRE on which the plug-in runs.
To find the JRE on which your plug-in runs, you first need to find the execution environment of your plug-in. Open the MANIFEST.MF
file of the plug-in and find the execution environment that the Bundle-RequiredExecutionEnvironment
attribute is set to, e.g., JavaSE-1.6
.
In Eclipse, each execution environment is mapped to a JRE installation. To find the JRE that your execution environment is set to go to Preferences -> Java -> Installed JREs -> Execution Environments
and click on the execution environment used by your plug-in.
You need to configure the JRE on which your plug-in runs. Go to Preferences -> Java -> Installed JREs
and select the JRE used by your plug-in. Press the Edit...
button and set the Default VM arguments
to -Xbootclasspath/p:/path/to/your/jar.jar
. Finally, click the Finish
button and then the OK
button on the preferences window.
You may be able to set the VM arguments in different places, e.g., on the launch configuration dialog of your Eclipse Application.