取决于Eclipse中的tools.jar(Sun JDK)中的com.sun.javadoc [英] Depending on com.sun.javadoc from tools.jar (Sun JDK) in Eclipse

查看:255
本文介绍了取决于Eclipse中的tools.jar(Sun JDK)中的com.sun.javadoc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的一个插件需要一个安装的JDK,而不仅仅是一个JRE。我们需要com.sun.javadoc和tools.jar的朋友。我不认为Sun的许可证将允许重新分发tools.jar(如果您已经有JDK,则不需要)。



Eclipse中似乎还没有办法指定一个JDK作为依赖关系。 Eclipse新闻组中的所有答案都表明最终用户必须首先正确配置Eclipse。



您是否知道任何解决方法会使这种依赖关系对我们的插件的用户显而易见,只是通过使用Eclipse的板载机制来实现依赖关系?似乎这个软件包对于清单中的 Import-Package 来说是不合适的。 com.sun.jdi。



(作为一个解决方法,目前我们只能警告插件激活该库缺失。)

$ b $由于eclipse提供了一个OSGi环境,你可以参考文章在OSGi中暴露引导类路径,并尝试使用:




  • a系统包声明

  • 扩展包(片段)声明

  • 或引导委派



通过指定您需要的JDK软件包,OSGI框架将尝试加载它们(如果没有,则失败)。

通过指定一个JDK5或JDK6,您甚至可以确保JDK的正确版本。


OSGi规范允许框架(通过其系统包)将其父类加载器中的任何相关包导出为系统包使用 org.osgi.framework.system.packages 属性。

重新包装主机 JDK 作为捆绑包不是一个可行的选项,可以使用此设置来使系统捆绑(或包含id为0)导出这些包本身。

最多的OSGi实现已经使用此属性导出所有公共JDK包(基于检测到的JDK版本)。以下是Java 1.6的Equinox配置文件的一个片段:




  org.osgi.framework .system.packages = \ 
javax.accessibility,\
javax.activity,\
javax.crypto,\
javax.crypto.interfaces,\
...
org.xml.sax.helpers




使用此属性,可以添加将由框架加载和提供的额外的包,并可以连接到其他捆绑包。




  org.osgi.framework.system.packages = \ 
javax.accessibility,\
javax.activity,\
...
org.xml.sax.helpers,\
special.parent.package






注意:指定 Bundle-RequiredExe cutionEnvironment 仅适用于JRE,而不是JDK ...






这种配置需要是Equinox框架的config.ini的一部分(请参阅 this Jetty的示例及其配置.ini )。

在您的情况下,它将在您的片段的config.ini中声明。


One of our plugins requires an installed JDK, not just an JRE. We need com.sun.javadoc and friends from tools.jar. I do not think Sun's license will allow redistributing tools.jar (which is not necessary if you already have a JDK anyway).

It also seems there is no way in Eclipse to specify a JDK as a dependency. All answers in the Eclipse newsgroups suggest that end users will have to configure their Eclipse properly first.

Do you know any workaround that will make this dependency obvious to users of our plugin, just by using Eclipse's on-board mechanisms for dependencies? It seems this package is not even valid for Import-Package in the manifest, unlike e.g. com.sun.jdi.

(As a work-around, currently we can only warn on plugin activation that this library is missing.)

解决方案

Since eclipse offers an OSGi environment, you could refer to the article "Exposing the boot classpath in OSGi", and try using:

  • a System Packages declaration
  • a Extension Bundles (Fragment) declaration
  • or boot delegation

By specifying the JDK packages you need, the OSGI framework will attempt to load them (and fail if there are not here).
By specifying one specific to JDK5 or JDK6, you could even ensure the right version of the JDK.

The OSGi spec allows the Framework (through its system bundle) to export any relevant packages from its parent class loader as system packages using the org.osgi.framework.system.packages property.
As repacking the hosting JDK as a bundle isn't a viable option, one can use this setting to have the system bundle (or the bundle with id 0) export these packages itself.
Most of the OSGi implementations already use this property to export all the public JDK packages (based on the detected JDK version). Below is a snippet from an Equinox configuration file for Java 1.6:

org.osgi.framework.system.packages = \
  javax.accessibility,\
  javax.activity,\
  javax.crypto,\
  javax.crypto.interfaces,\
  …
  org.xml.sax.helpers

Using this property, one can add extra packages that will be loaded and provided by the framework and that can be wired to other bundles.

org.osgi.framework.system.packages = \
  javax.accessibility,\
  javax.activity,\
  …
  org.xml.sax.helpers, \
  special.parent.package


Note: the simpler solution of specifying Bundle-RequiredExecutionEnvironment is only for the JRE, not the JDK...


That kind of configuration need to be part of the config.ini of the Equinox framework (see this example for Jetty and its config.ini).
In your case, it would be declared in the config.ini of your fragment.

这篇关于取决于Eclipse中的tools.jar(Sun JDK)中的com.sun.javadoc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆