简体   繁体   English

如何配置Eclipse插件的bootstrap类路径?

[英]How to configure the bootstrap classpath of an Eclipse plug-in?

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. 我想替换我的Eclipse插件依赖于我自己的这些类的版本的rt.jar一些类( javax.tools.* )。 Replacing the classes in rt.jar is typically done by setting the bootclasspath. 替换rt.jar的类通常通过设置bootclasspath来完成。 My question is how to do this in an Eclipse plug-in. 我的问题是如何在Eclipse插件中执行此操作。

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 . 我创建了这些类的版本的JAR文件,并将其添加到MANIFEST.MFBundle-ClassPath属性, build.propertiesbin.includes属性和.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". 我还将我的JAR文件的路径输入到Eclipse Application启动配置对话框的名为“Bootstrap entries:”的字段中,并将我的JAR移动到“Project Properties> Build Path”的“Order and Export”选项卡中的顶部。 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. 尽管如此,当我使用Eclipse Application启动配置运行Eclipse插件时,插件使用rt.jar的原始类而不是我的JAR文件中的类。

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? 我如何配置我的Eclipse插件,以便它首先查找我的JAR文件中的类,并且只有在我的JAR文件中找不到类时才参考rt.jar

The solution that I found is to configure the JRE on which the plug-in runs. 我找到的解决方案是配置插件运行的JRE。

To find the JRE on which your plug-in runs, you first need to find the execution environment of your plug-in. 要查找运行插件的JRE,首先需要找到插件的执行环境。 Open the MANIFEST.MF file of the plug-in and find the execution environment that the Bundle-RequiredExecutionEnvironment attribute is set to, eg, JavaSE-1.6 . 打开插件的MANIFEST.MF文件,找到Bundle-RequiredExecutionEnvironment属性设置为的执行环境,例如JavaSE-1.6

In Eclipse, each execution environment is mapped to a JRE installation. 在Eclipse中,每个执行环境都映射到JRE安装。 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. 要找到执行环境设置为的JRE,请转到Preferences -> Java -> Installed JREs -> Execution Environments ,然后单击插件使用的执行环境。

You need to configure the JRE on which your plug-in runs. 您需要配置运行插件的JRE。 Go to Preferences -> Java -> Installed JREs and select the JRE used by your plug-in. 转到Preferences -> Java -> Installed JREs然后选择插件使用的JRE。 Press the Edit... button and set the Default VM arguments to -Xbootclasspath/p:/path/to/your/jar.jar . Edit...按钮并将Default VM arguments设置为-Xbootclasspath/p:/path/to/your/jar.jar Finally, click the Finish button and then the OK button on the preferences window. 最后,单击“ Finish按钮,然后OK首选项窗口上的“ OK按钮。

You may be able to set the VM arguments in different places, eg, on the launch configuration dialog of your Eclipse Application. 您可以在不同的位置设置VM参数,例如,在Eclipse Application的启动配置对话框中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM