Java 在 jdk1.6 中使用 Endorsed 目录的确切方法是什么
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2859471/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
what is the exact way to use Endorsed directory in jdk1.6
提问by Persimmonium
I want to upgrade my jaxws to 2.2 (jdk1.6 comes bundled with jaxws 2.1). My jdk is (I did not install public jre):
我想将我的 jaxws 升级到 2.2(jdk1.6 与 jaxws 2.1 捆绑在一起)。我的 jdk 是(我没有安装公共 jre):
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode)
In jaxws' own docthey explain how to do it:
在jaxws 自己的文档中,他们解释了如何做到这一点:
One way to fix this is to copy jaxws-api.jar and jaxb-api.jar into JRE endorsed directory, which is $JAVA_HOME/lib/endorsed (or $JDK_HOME/jre/lib/endorsed)
解决此问题的一种方法是将 jaxws-api.jar 和 jaxb-api.jar 复制到 JRE 认可的目录中,即 $JAVA_HOME/lib/endorsed (or $JDK_HOME/jre/lib/endorsed)
But I am not sure this is having any effect in my installation. For starters I have only defined %JAVA_HOME%
. And folder $JAVA_HOME/lib/endorsed
is inexistant, so I created and copied the two jars. But if I do (wsgen is a tool from jaxws)
但我不确定这对我的安装有任何影响。首先,我只定义了%JAVA_HOME%
. 而且文件夹$JAVA_HOME/lib/endorsed
不存在,所以我创建并复制了两个罐子。但是如果我这样做(wsgen 是 jaxws 的一个工具)
wsgen -version
I still get:
我仍然得到:
JAX-WS RI 2.1.6 in JDK 6
I also tried creating folder JAVA_HOME\jre\lib\endorsed
(notice that in the doc they say JDK_HOME, but as I only have JAVA_HOME I used this path). Still same wsgen output.
我还尝试创建文件夹JAVA_HOME\jre\lib\endorsed
(请注意,在文档中他们说 JDK_HOME,但由于我只有 JAVA_HOME,因此我使用了此路径)。仍然相同的 wsgen 输出。
My questions are:
我的问题是:
- What is the difference between JAVA_HOME and JDK_HOME in the doc page? anything significant or just two ways to refer to JAVA_HOME ?
- Is 'wsgen -version' a valid way to check jaxws version that is used or this always calls the exe in the original jdk, but it does not mean endorsed jars will be used?
- Anyone knows very detailed stepsto install jaxws2.2 in a jdk.16?
- 文档页面中的 JAVA_HOME 和 JDK_HOME 有什么区别?有什么重要的或只是两种引用 JAVA_HOME 的方式?
- 'wsgen -version' 是检查使用的 jaxws 版本的有效方法,还是总是调用原始 jdk 中的 exe,但这并不意味着将使用认可的 jars?
- 有人知道在 jdk.16 中安装 jaxws2.2 的非常详细的步骤吗?
I found this postthat has some hints about what I am seeing I think
我发现这篇文章对我所看到的东西有一些提示,我认为
采纳答案by Daniel
The wsimport and wsgen included in the jre are located in the jre/bin directory as exe and if you still call it from command line, it will still run the Jax-WS 2.1 implementation.
jre 中包含的 wsimport 和 wsgen 作为 exe 位于 jre/bin 目录中,如果您仍然从命令行调用它,它仍将运行 Jax-WS 2.1 实现。
To update to Jax-WS 2.2, you need to download the relevant JAX-WS 2.2.X RI from the jaxws website.
要更新到 Jax-WS 2.2,您需要从 jaxws 网站下载相关的 JAX-WS 2.2.X RI。
You need to extract the contents onto your computer.
您需要将内容提取到您的计算机上。
You also need to copy the jaxws-api.jar and jaxb-api.jar into the endorsed directory (as per your original description)
您还需要将 jaxws-api.jar 和 jaxb-api.jar 复制到认可目录中(根据您的原始描述)
HOWEVER, instead of using wsgen.exe or wsimport.exe (as applicable to your project), you now need to use the one provided in the jax-ws 2.2 update/download.
但是,您现在需要使用 jax-ws 2.2 更新/下载中提供的,而不是使用 wsgen.exe 或 wsimport.exe(适用于您的项目)。
In the jaxws-ri directory that you've extracted from your JAX-WS 2.2 download, you will see a bin directory and 4 files (wsgen.bat, wsgen.sh, wsimport.bat, wsimport.sh) and these are the ones which you need to run instead.
在从 JAX-WS 2.2 下载中提取的 jaxws-ri 目录中,您将看到一个 bin 目录和 4 个文件(wsgen.bat、wsgen.sh、wsimport.bat、wsimport.sh),这些就是你需要运行它。
To run them, you have to set up the JAXWS_HOME environment variable (see the wsgen/wsimport.bat/sh files for details).
要运行它们,您必须设置 JAXWS_HOME 环境变量(有关详细信息,请参阅 wsgen/wsimport.bat/sh 文件)。
That should now allow you to run JAX-WS 2.2 with JDK 1.6
现在应该允许您使用 JDK 1.6 运行 JAX-WS 2.2
回答by Yishai
It isn't tied to your environment variables. %JAVA_HOME% is just shorthand in the documentation that doesn't know where you installed Java or what version of Java you installed.
它与您的环境变量无关。%JAVA_HOME% 只是文档中不知道您安装 Java 的位置或安装的 Java 版本的简写。
%JAVA_HOME% refers to a JRE (the regular runtime a non-developer would have). %JDK_HOME% refers to the rood directory of a JDK, a Java Development Kit, something a developer would use.
%JAVA_HOME% 指的是 JRE(非开发人员将拥有的常规运行时)。%JDK_HOME% 指的是 JDK 的 rood 目录,这是一个开发人员会使用的 Java 开发工具包。
More than that, you have to know when you run wsgen where it is being run from, and that the corresponding JVM is configured with an endorsed directory that contains the jars.
更重要的是,您必须知道何时运行 wsgen 是从哪里运行的,并且相应的 JVM 配置了一个包含 jar 的认可目录。
回答by Saintali
You should check you system property java.endorsed.dirs
, e.g. by calling System.getProperty("java.endorsed.dirs")
. On a Windows machine, this is usually something like C:\Program Files\Java\jdk1.6.0_16\jre\lib\endorsed
. Put the jar files you want to endorse here. If that directory does not exist just create it.
您应该检查您的系统属性java.endorsed.dirs
,例如通过调用System.getProperty("java.endorsed.dirs")
. 在 Windows 机器上,这通常类似于C:\Program Files\Java\jdk1.6.0_16\jre\lib\endorsed
. 把你要背书的jar文件放在这里。如果该目录不存在,只需创建它。
Another option is to put the jars in a directory of your own preference, but override the system property by adding a command line switch -Djava.endorsed.dirs=<Your endorsed jars directory>
.
另一种选择是将 jars 放在您自己喜欢的目录中,但通过添加命令行开关来覆盖系统属性-Djava.endorsed.dirs=<Your endorsed jars directory>
。