如何检查计算机上是否安装了java
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18888220/
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
How to check whether java is installed on the computer
提问by Sandeep Sehrawat
I am trying to install java windows application on client machine.I want to check whether requried JRE is installed on the machine or not. I want to check it by java program not by cmd command
我正在尝试在客户端机器上安装 java windows 应用程序。我想检查机器上是否安装了所需的 JRE。我想通过java程序而不是cmd命令来检查它
采纳答案by SpringLearner
if you are using windows or linux operating system then type in command prompt / terminal
如果您使用的是 windows 或 linux 操作系统,请输入命令提示符/终端
java -version
If java is correctly installed then you will get something like this
如果java安装正确,那么你会得到这样的东西
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode, sharing)
Side note: After installation of Java on a windows operating system, the PATH variable is changed to add java.exe so you need to re-open cmd.exe to reload the PATH variable.
附注:在windows操作系统上安装Java后,PATH变量被更改为添加java.exe,因此您需要重新打开cmd.exe以重新加载PATH变量。
Edit:
编辑:
CD to the path first...
先CD到路径...
cd C:\ProgramData\Oracle\Java\javapath
java -version
回答by dharam
Go to this link and wait for a while to load.
转到此链接并等待一段时间加载。
http://www.java.com/en/download/testjava.jsp
http://www.java.com/en/download/testjava.jsp
You will see the below image:
您将看到下图:
You can alternatively open command window and type java -version
您也可以打开命令窗口并键入 java -version
回答by bNd
command prompt:
命令提示符:
C:\Users\admin>java -version (Press Enter>
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
回答by SudoRahul
After installing Java, set the path in environmental variables and then open the command prompt and type java -version
. If installed properly, it'll list the java version, jre version, etc.
安装 Java 后,在环境变量中设置路径,然后打开命令提示符并键入java -version
. 如果安装正确,它会列出 java 版本、jre 版本等。
You can additionally check by trying the javac
command too. If it displays some data, you've your java installed with the proper path set, else it'll that javac
is an invalid command.
您也可以通过尝试javac
命令来额外检查。如果它显示一些数据,则说明您已使用正确的路径集安装了 java,否则它将javac
是无效命令。
回答by Theolodis
Type in the command window
在命令窗口中输入
java -version
If it gives an output everything should be fine. If you want to develop software you might want to set the PATH.
如果它给出输出,一切都应该没问题。如果您想开发软件,您可能需要设置 PATH。
回答by M. Abbas
Open Command Prompt and type in the following command: java -version
打开命令提示符并输入以下命令: java -version
Upon successful execution, the command will output the version of Java along with Java SE Runtime Environment's build and Java HotSpot Client VM's build.
成功执行后,该命令将输出 Java 版本以及 Java SE 运行时环境的构建和 Java HotSpot 客户端 VM 的构建。
回答by A4L
You can do it programmatically by reading the java
system properties
您可以通过读取java
系统属性以编程方式执行此操作
@Test
public void javaVersion() {
System.out.println(System.getProperty("java.version"));
System.out.println(System.getProperty("java.runtime.version"));
System.out.println(System.getProperty("java.home"));
System.out.println(System.getProperty("java.vendor"));
System.out.println(System.getProperty("java.vendor.url"));
System.out.println(System.getProperty("java.class.path"));
}
This will output somthing like
这将输出类似
1.7.0_17
1.7.0_17-b02
C:\workspaces\Oracle\jdk1.7\jre
Oracle Corporation
http://java.oracle.com/
C:\workspaces\Misc\Miscellaneous\bin; ...
The first line shows the version number. You can parse it an see whether it fits your minimun required java version or not. You can find a description for the naming convention hereand more infos here.
第一行显示版本号。您可以对其进行解析,看看它是否适合您所需的最低 Java 版本。你可以找到的命名约定的描述在这里和更多的相关信息在这里。
回答by jiggunjer
Check the installation directories (typically C:\Program Files (x86)
or C:\Program Files
) for the java folder. If it contains the JRE you have java installed.
检查java 文件夹的安装目录(通常为C:\Program Files (x86)
或C:\Program Files
)。如果它包含 JRE,则您已经安装了 java。
回答by user7230169
type java -versionin command prompt, it will give you the installed version of java on your system.
在命令提示符下键入java -version,它将为您提供系统上已安装的 java 版本。
回答by zaursh
1)Open the command prompt or terminal based on your OS.
1) 根据您的操作系统打开命令提示符或终端。
2)Then type java --version
in the terminal.
2)然后java --version
在终端中输入。
3) If java is installed successfullly it will show the respective version .
3)如果java安装成功,它会显示相应的版本。