问题描述
我最近检查了我的Java版本.我运行命令java -version
,发现我正在使用java version 1.7.0_09
.但是,当我尝试检查C:\Program Files\Java\
目录时,我似乎找不到相同的版本.我只看到以下内容:
I have recently checked on my Java version. I ran the command java -version
and I found out that I was using java version 1.7.0_09
. But when I tried to check on C:\Program Files\Java\
directory, I don't seem to find the same version. I only see the following:
- j2re1.4
- jdk1.6.0_32
- jdk1.7.0_06
- jdk1.7.0_07
- jre6
- jre7
依此类推...
我的程序仍在运行,但我只是尝试手动编译所有内容,并了解操作系统如何处理Java.
My programs still run, but I'm just trying to compile everything manually, and understand how Java is being treated by the OS.
另一件事很奇怪,我尝试检查环境变量设置,但它没有说明jdk1.7.0_09
.
Another thing that is weird is, I tried to check on environment variable settings, and it does not say anything about jdk1.7.0_09
.
路径:
- C:\ Program Files \ Common Files \ Microsoft Shared \ Windows Live;
- %SystemRoot%\ system32;
- %SystemRoot%;
- %SystemRoot%\ System32 \ Wbem;
- %SYSTEMROOT%\ System32 \ WindowsPowerShell \ v1.0 \;
- C:\ Program Files \ TortoiseSVN \ bin;
- C:\ Program Files \ Windows Live \ Shared;
- C:\ eclipse \ plugins \ com.google.appengine.eclipse.sdkbundle_1.6.5 \ appengine-java-sdk-1.6.5 \ bin;
- C:\ Program Files \ Java \ jdk1.7.0_07 \ bin; C:\ Program Files \ QuickTime \ QTSystem \;
- %ANT_HOME%\ bin
- C:\Program Files\Common Files\Microsoft Shared\Windows Live;
- %SystemRoot%\system32;
- %SystemRoot%;
- %SystemRoot%\System32\Wbem;
- %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;
- C:\Program Files\TortoiseSVN\bin;
- C:\Program Files\Windows Live\Shared;
- C:\eclipse\plugins\com.google.appengine.eclipse.sdkbundle_1.6.5\appengine-java-sdk-1.6.5\bin;
- C:\Program Files\Java\jdk1.7.0_07\bin;C:\Program Files\QuickTime\QTSystem\;
- %ANT_HOME%\bin
只想让你们知道它以某种方式自动变成了jre.
Just want to let you guys know that it somehow automatically became a jre.
完整目录为C:\Users\User02\AppData\LocalLow\Sun\Java\jre1.7.0_09
,仅得到名为lzma.dll
的文件.
The complete directory is C:\Users\User02\AppData\LocalLow\Sun\Java\jre1.7.0_09
and it's just got the file named lzma.dll
.
但是,我还有另一个目录,显示为C:\Users\User02\AppData\LocalLow\Sun\Java\jdk1.7.0_07
.其中的文件是:
But, I have another directory that says C:\Users\User02\AppData\LocalLow\Sun\Java\jdk1.7.0_07
. The files inside it are:
- jdk1.7.0_07.msi
- sj170070.cab
- ss170070.cab
- st170070.cab
- 和sz170070.cab
推荐答案
在计算机上可以并排放置许多JRE.
It's possible to have many JRE side-by-side on a computer.
如果在Windows上正确安装了JRE,则有关每个版本的信息都存储在注册表中.安装过程将在系统PATH(%SYSTEMROOT%\ System32 )中安装特殊的java.exe .因此,您无需更改PATH,因为此特殊的java.exe将找到当前的JRE.在命令行中,键入java -version以显示当前安装的jre版本.
If the JRE is properly installed on Windows, informations about each version are stored in the registry. The installation process installs a special java.exe in the system PATH (%SYSTEMROOT%\System32). So you don't need to alter you PATH because this special java.exe will find the current JRE. From a command line, type java -version to display the current jre version installed.
在1.6版中,现在可以选择与上一个版本不同的JRE安装,而无需进行任何注册表修改.
With release 1.6, it's now possible to select a different JRE installation than the last one without any registry modification.
JRE安装在注册表中的项
The JRE installation are listed in the registry in the key
参加这个简单的测试课程
Take this simple test class
public class ShowVersion {
public static void main(String args[]) {
System.out.println(System.getProperty("java.version"));
}
}
在安装了1.6和1.5的系统上.如果您输入
On a system, with 1.6 and 1.5 installed. If you type
> java ShowVersion
自从上次安装以来,大概将使用1.6 JRE.
It's probably the 1.6 JRE that will be used since it's the last installed.
要强制使用1.5 JRE,请使用此命令行.
To force the 1.5 JRE instead, use this command line.
> java -version:"1.5" ShowVersion
如果字节码与给定的JRE不兼容,那么..当然不起作用.
If the bytecode is incompatible with the given JRE then .. it won't work, of course.
ref: technote Java 6
您始终可以提供使用特定安装的完整路径.以这种方式启动JVM根本不使用注册表设置.
You can always give the complete path to use a specific installation. Launching the JVM this way does not use the registry setting at all.
>"C:\Program Files\Java\j2re1.4.1_02\bin\java" -version
java version "1.4.1_02"
source:从命令行中选择特定的JRE
这篇关于命令行上显示了不同的Java版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!