在 Windows 10 中设置环境变量以使用 java 和 javac
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32241179/
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
Setting up enviromental variables in Windows 10 to use java and javac
提问by kilmarta
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.
我有一台装有 Windows 10 的新笔记本电脑,我想对其进行设置,以便我可以从命令行使用java
和javac
。
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.
我在网上搜索过,但所有的指南都是针对以前的版本的,我不想乱搞我不明白的东西。
回答by whitecoffee
Its still the same concept, you'll need to setup path variable so that windows is aware of the java executable and u can run it from command prompt conveniently
它仍然是相同的概念,您需要设置路径变量,以便 Windows 知道 java 可执行文件,并且您可以方便地从命令提示符运行它
Details from the java's own page: https://java.com/en/download/help/path.xmlThat article applies to: ?Platform(s): Solaris SPARC, Solaris x86, Red Hat Linux, SUSE Linux, Windows 8, Windows 7, Vista, Windows XP, Windows 10
来自 java 自己页面的详细信息:https: //java.com/en/download/help/path.xml该文章适用于:?平台:Solaris SPARC、Solaris x86、Red Hat Linux、SUSE Linux、Windows 8 、Windows 7、Vista、Windows XP、Windows 10
回答by isurujay
Just set the path variable to JDK bin in environment variables.
只需在环境变量中将路径变量设置为 JDK bin 即可。
Variable Name : PATH
Variable Value : C:\Program Files\Java\jdk1.8.0_31\bin
But the best practice is to set JAVA_HOME and PATH as follow.
但最好的做法是设置 JAVA_HOME 和 PATH 如下。
Variable Name : JAVA_HOME
Variable Value : C:\Program Files\Java\jdk1.8.0_31
Variable Name : PATH
Variable Value : %JAVA_HOME%\bin
回答by theINtoy
To find the env vars dialog in Windows 10:
在 Windows 10 中查找 env vars 对话框:
Right Click Start
>> Click Control Panel (Or you may have System in the list)
>> Click System
>> Click Advanced system settings
>> Go to the Advanced Tab
>> Click the "Environment Variables..." button at the bottom of that dialog page.
回答by Navin prasad
- Right click Computer
- Click the properties
- On the left pane select Advanced System Settings
- Select Environment Variables
- Under the System Variables, Select PATHand click edit,
and then click newand add path as C:\Program
Files\Java\jdk1.8.0_131\bin(depending on your installation path)
and finally click ok - Next restart your command prompt and open it and try javac
- 右键单击计算机
- 点击属性
- 在左侧窗格中选择高级系统设置
- 选择环境变量
- 在系统变量下,选择PATH并单击编辑,
然后单击新建并将路径添加为C:\Program
Files\Java\jdk1.8.0_131\bin(取决于您的安装路径)
,最后单击确定 - 接下来重新启动命令提示符并打开它并尝试javac
回答by Chandra Shekhar Goka
Here are the typical steps to set JAVA_HOME on Windows 10.
以下是在 Windows 10 上设置 JAVA_HOME 的典型步骤。
- Search for Advanced System Settings in your windows Search box. Click on Advanced System Settings.
- Click on Environment variablesbutton: Environment Variables popup will open.
- Goto system variables session, and click on New button to create new variable (HOME_PATH), then New System Variables popup will open.
- Give Variable Name: JAVA_HOME, and Variable value : Your Java SDK home path. Ex: C:\Profram files\java\jdk1.8.0_151Note: It should not include \bin. Then click on OK button.
- Now you are able to see your JAVA_HOME in system variables list.
- Select Path(from system variables list) and click on Edit button, A new pop will opens (Edit Environment Variables). It was introduced in windows 10.
- Click on New button and give %JAVA_HOME%\binat highlighted field and click Ok button.
- 在 Windows 搜索框中搜索高级系统设置。单击高级系统设置。
- 单击环境变量按钮:环境变量弹出窗口将打开。
- 转到system variables session,然后单击 New 按钮创建新变量 (HOME_PATH),然后将打开 New System Variables 弹出窗口。
- 提供变量名称:JAVA_HOME和变量值:您的 Java SDK 主路径。例如:C:\Profram files\java\jdk1.8.0_151注意:它不应包含\bin。然后单击确定按钮。
- 现在您可以在系统变量列表中看到您的 JAVA_HOME。
- 选择路径(从系统变量列表中)并单击编辑按钮,将打开一个新的弹出窗口(编辑环境变量)。它是在 Windows 10 中引入的。
- 单击“新建”按钮并在突出显示的字段中输入%JAVA_HOME%\bin,然后单击“确定”按钮。
You can find complete tutorials on my blog :
你可以在我的博客上找到完整的教程: