在 Windows 10 中设置环境变量以使用 java 和 javac

问题描述:

我有一台装有 Windows 10 的新笔记本电脑,我想对其进行设置,以便我可以从命令行使用 javajavac.

I got a new laptop with Windows 10 and I want to set it up so I can use java and javac from the command line.

我已经在网上搜索过,但所有指南都是针对以前版本的,我不想乱搞我不明白的东西.

I have searched online but all the guides are for previous versions, and I don't want to mess around with something I don't understand.

只需在环境变量中设置路径变量为JDK bin即可.

Just set the path variable to JDK bin in environment variables.

Variable Name : PATH 
Variable Value : C:Program FilesJavajdk1.8.0_31in

但最好的做法是设置JAVA_HOME和PATH如下.

But the best practice is to set JAVA_HOME and PATH as follow.

Variable Name : JAVA_HOME
Variable Value : C:Program FilesJavajdk1.8.0_31

Variable Name : PATH 
Variable Value : %JAVA_HOME%in