本文介绍了java安装的环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Windows中设置Java的环境变量(类路径)?
How to set the environment variables for Java in Windows (the classpath)?
推荐答案
Java SE开发工具包8u112 on a 64位Windows 7或Windows 8
设置以下用户环境变量(= = 用户变量类型的环境变量)
-
JAVA_HOME:
C:\ Program Files\Java\jdk1.8.0_112
-
JDK_HOME:
%JAVA_HOME%
-
JRE_HOME:
%JAVA_HOME%\ jre
-
CLASSPATH:
。;%JAVA_HOME%\ lib;%JAVA_HOME%\\ \\ jre\lib
-
路径:
your-unique-entries; %JAVA_HOME%\ bin
(确保较长的your-unique-entries
不包含对其他Java安装文件夹的任何其他引用。
JAVA_HOME :
C:\Program Files\Java\jdk1.8.0_112
JDK_HOME :
%JAVA_HOME%
JRE_HOME :
%JAVA_HOME%\jre
CLASSPATH :
.;%JAVA_HOME%\lib;%JAVA_HOME%\jre\lib
PATH :
your-unique-entries;%JAVA_HOME%\bin
(make sure that the longishyour-unique-entries
does not contain any other references to another Java installation folder.
请注意,这些环境变量来自mroot环境变量 JAVA_HOME
。这样可以在更新JDK时轻松更新环境变量。只需将 JAVA_HOME
指向全新安装。
Notice that these environment variables are derived from the "root" environment variable JAVA_HOME
. This makes it easy to update your environment variables when updating the JDK. Just point JAVA_HOME
to the fresh installation.
。
- 使用值添加用户环境变量
JAVA_TOOL_OPTIONS
-Dfile.encoding = UTF-8
。这可确保Java(以及 Maven 等工具)使用UTF-8的
(而不是默认的Charset.defaultCharset()
运行Windows-1252
)。在使用我自己的代码和其他代码进行wirking时,这已经避免了很多麻烦,不幸的是,这些代码经常采用(理智的)默认编码 UTF-8 。 - 安装JDK时,它会添加到系统环境变量
路径
条目C:\ProgramData \ Oracle \\ \\Java\javapath;
。我有趣地注意到,在JDK安装更新期间,该目录中的链接没有得到更新。所以最好从Path
系统中删除C:\ProgramData \ Oracle \ Java \ _javapath;
环境变量,以便拥有一致的环境。
- Add an user environment variable
JAVA_TOOL_OPTIONS
with value-Dfile.encoding="UTF-8"
. This ensures that Java (and tools such as Maven) will run with aCharset.defaultCharset()
ofUTF-8
(instead of the defaultWindows-1252
). This has saved a lot of headaches when wirking with my own code and that of others, which unfortunately often assume the (sane) default encoding UTF-8. - When JDK is installed, it adds to the system environment variable
Path
an entryC:\ProgramData\Oracle\Java\javapath;
. I anecdotally noticed that the links in that directory didn't get updated during an JDK installation update. So it's best to removeC:\ProgramData\Oracle\Java\javapath;
from thePath
system environment variable in order to have a consistent environment.
这篇关于java安装的环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!