简体   繁体   English

取决于Eclipse中tools.jar(Sun JDK)的com.sun.javadoc

[英]Depending on com.sun.javadoc from tools.jar (Sun JDK) in Eclipse

One of our plugins requires an installed JDK, not just an JRE. 我们的一个插件需要安装JDK,而不仅仅是JRE。 We need com.sun.javadoc and friends from tools.jar. 我们需要来自tools.jar的com.sun.javadoc和朋友。 I do not think Sun's license will allow redistributing tools.jar (which is not necessary if you already have a JDK anyway). 我不认为Sun的许可证会允许重新分发tools.jar(如果你已经拥有JDK则不需要)。

It also seems there is no way in Eclipse to specify a JDK as a dependency. Eclipse中似乎也没有办法将JDK指定为依赖项。 All answers in the Eclipse newsgroups suggest that end users will have to configure their Eclipse properly first. Eclipse新闻组中的所有答案都表明最终用户必须首先正确配置他们的Eclipse。

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 ? 你知道任何一种解决方法, 只是通过使用Eclipse的依赖性机载机制,使这个依赖对我们插件的用户显而易见吗? It seems this package is not even valid for Import-Package in the manifest, unlike eg com.sun.jdi. 看来这个包甚至对清单中的Import-Package都没有效,不像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: 由于eclipse提供了OSGi环境,您可以参考文章“ 在OSGi中公开引导类路径 ”,并尝试使用:

  • 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). 通过指定所需的JDK包,OSGI框架将尝试加载它们(如果没有,则会失败)。
By specifying one specific to JDK5 or JDK6, you could even ensure the right version of the JDK. 通过指定一个特定于JDK5或JDK6,您甚至可以确保正确的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. OSGi规范允许Framework(通过其系统包)使用org.osgi.framework.system.packages属性从其父类加载器导出任何相关的包作为系统包。
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. 由于将托管JDK重新打包为捆绑包不是一个可行的选项,因此可以使用此设置使系统捆绑包(或ID为0的捆绑包)自行导出这些包。
Most of the OSGi implementations already use this property to export all the public JDK packages (based on the detected JDK version). 大多数OSGi实现已经使用此属性导出所有公共JDK包(基于检测到的JDK版本)。 Below is a snippet from an Equinox configuration file for Java 1.6: 以下是来自Java 1.6的Equinox配置文件的片段:

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... 注意:指定Bundle-RequiredExecutionEnvironment的更简单的解决方案仅适用于JRE,而不是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 ). 这种配置需要成为Equinox框架的config.ini的一部分(请参阅Jetty及其config.ini的 此示例 )。
In your case, it would be declared in the config.ini of your fragment. 在您的情况下,它将在您的片段的config.ini中声明。

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

相关问题 导入com.sun.javadoc,与Eclipse和Ant结合使用 - Import com.sun.javadoc, using with Eclipse and Ant 导入com.sun.javadoc无法在Eclipse中解析 - The import com.sun.javadoc cannot be resolved in Eclipse tools.jar 未打包到 maven package 中。 获取 java.lang.NoClassDefFoundError: com/sun/tools/javadoc/Main - tools.jar not packaged into the maven package. Getting java.lang.NoClassDefFoundError: com/sun/tools/javadoc/Main cxf-codegen-plugin could not find artifact com.sun:tools:jar:1.8.0 from C:\Program Files\Java\jre1.8.0_251/../lib/tools.jar - cxf-codegen-plugin could not find artifact com.sun:tools:jar:1.8.0 from C:\Program Files\Java\jre1.8.0_251/../lib/tools.jar 如何在没有 JDK 的情况下从 tools.jar 使用 JavaCompiler - How to use JavaCompiler from tools.jar without JDK maven项目需要sun.javadoc jar - maven project required sun.javadoc jar 如何参考工具.jar from Eclipse,不管路径 - How to reference tools.jar from Eclipse, regardless of path libGDX和Eclipse-找不到tools.jar - libGDX and Eclipse - Could not find tools.jar 您需要使用JDK运行构建或在类路径上使用tools.jar - You need to run build with JDK or have tools.jar on the classpath 缺少神器“sun.jdk:jconsole:jar:jdk” - Missing artifact "sun.jdk:jconsole:jar:jdk"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM