linux配置java环境变量(详细)
一. 解压安装jdk
在shell终端下进入jdk-6u14-linux-i586.bin文件所在目录,
执行命令 ./jdk-6u14-linux-i586.bin 这时会出现一段协议,连继敲回车,当询问是否同意的时候,输入yes,回车。之后会在当前目录下生成一个jdk1.6.0_14目录,你可以将它复制到 任何一个目录下。
二. 需要配置的环境变量
1. PATH环境变量。作用是指定命令搜索路径,在shell下面执行命令时,它会到PATH变量所指定的路径中查找看是否能找到相应的命令程序。我们需要把 jdk安装目录下的bin目录增加到现有的PATH变量中,bin目录中包含经常要用到的可执行文件如javac/java/javadoc等待,设置好 PATH变量后,就可以在任何目录下执行javac/java等工具了。
2. CLASSPATH环境变量。作用是指定类搜索路径,要使用已经编写好的类,前提当然是能够找到它们了,JVM就是通过CLASSPTH来寻找类的。我们 需要把jdk安装目录下的lib子目录中的dt.jar和tools.jar设置到CLASSPATH中,当然,当前目录“.”也必须加入到该变量中。
3. JAVA_HOME环境变量。它指向jdk的安装目录,Eclipse/NetBeans/Tomcat等软件就是通过搜索JAVA_HOME变量来找到并使用安装好的jdk。
三. 三种配置环境变量的方法1. 修改/etc/profile文件
如果你的计算机仅仅作为开发使用时推荐使用这种方法,因为所有用户的shell都有权使用这些环境变量,可能会给系统带来安全性问题。
·用文本编辑器打开/etc/profile
·在profile文件末尾加入:
export JAVA_HOME=/usr/share/jdk1.6.0_14
export PATH=<nobr><span class="math" id="MathJax-Span-1" style="width: 10.669em; display: inline-block;"><span style="display: inline-block; position: relative; width: 8.536em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.816em 1000em 3.149em -0.424em); top: -2.717em; left: 0.003em;"><span class="mrow" id="MathJax-Span-2"><span class="mi" id="MathJax-Span-3" style="font-family: MathJax_Math-italic;">J<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mi" id="MathJax-Span-4" style="font-family: MathJax_Math-italic;">A</span><span class="mi" id="MathJax-Span-5" style="font-family: MathJax_Math-italic;">V<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.163em;"></span></span><span class="msubsup" id="MathJax-Span-6"><span style="display: inline-block; position: relative; width: 1.443em; height: 0px;"><span style="position: absolute; clip: rect(1.709em 1000em 2.723em -0.424em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-7" style="font-family: MathJax_Math-italic;">A</span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.291em; left: 0.749em;"><span class="mi" id="MathJax-Span-8" style="font-size: 70.7%; font-family: MathJax_Math-italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.456em;"></span></span></span></span><span class="mi" id="MathJax-Span-9" style="font-family: MathJax_Math-italic;">O</span><span class="mi" id="MathJax-Span-10" style="font-family: MathJax_Math-italic;">M<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mi" id="MathJax-Span-11" style="font-family: MathJax_Math-italic;">E<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="texatom" id="MathJax-Span-12"><span class="mrow" id="MathJax-Span-13"><span class="mo" id="MathJax-Span-14" style="font-family: MathJax_Main;">/</span></span></span><span class="mi" id="MathJax-Span-15" style="font-family: MathJax_Math-italic;">b</span><span class="mi" id="MathJax-Span-16" style="font-family: MathJax_Math-italic;">i</span><span class="mi" id="MathJax-Span-17" style="font-family: MathJax_Math-italic;">n</span><span class="mo" id="MathJax-Span-18" style="font-family: MathJax_Main; padding-left: 0.269em;">:</span></span><span style="display: inline-block; width: 0px; height: 2.723em;"></span></span></span><span style="border-left: 0.003em solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.397em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-1">JAVA_HOME/bin:</script>PATH
export CLASSPATH=.:<nobr><span class="math" id="MathJax-Span-19" style="width: 14.349em; display: inline-block;"><span style="display: inline-block; position: relative; width: 11.469em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.816em 1000em 3.149em -0.424em); top: -2.717em; left: 0.003em;"><span class="mrow" id="MathJax-Span-20"><span class="mi" id="MathJax-Span-21" style="font-family: MathJax_Math-italic;">J<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mi" id="MathJax-Span-22" style="font-family: MathJax_Math-italic;">A</span><span class="mi" id="MathJax-Span-23" style="font-family: MathJax_Math-italic;">V<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.163em;"></span></span><span class="msubsup" id="MathJax-Span-24"><span style="display: inline-block; position: relative; width: 1.443em; height: 0px;"><span style="position: absolute; clip: rect(1.709em 1000em 2.723em -0.424em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-25" style="font-family: MathJax_Math-italic;">A</span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.291em; left: 0.749em;"><span class="mi" id="MathJax-Span-26" style="font-size: 70.7%; font-family: MathJax_Math-italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.456em;"></span></span></span></span><span class="mi" id="MathJax-Span-27" style="font-family: MathJax_Math-italic;">O</span><span class="mi" id="MathJax-Span-28" style="font-family: MathJax_Math-italic;">M<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mi" id="MathJax-Span-29" style="font-family: MathJax_Math-italic;">E<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="texatom" id="MathJax-Span-30"><span class="mrow" id="MathJax-Span-31"><span class="mo" id="MathJax-Span-32" style="font-family: MathJax_Main;">/</span></span></span><span class="mi" id="MathJax-Span-33" style="font-family: MathJax_Math-italic;">l</span><span class="mi" id="MathJax-Span-34" style="font-family: MathJax_Math-italic;">i</span><span class="mi" id="MathJax-Span-35" style="font-family: MathJax_Math-italic;">b</span><span class="texatom" id="MathJax-Span-36"><span class="mrow" id="MathJax-Span-37"><span class="mo" id="MathJax-Span-38" style="font-family: MathJax_Main;">/</span></span></span><span class="mi" id="MathJax-Span-39" style="font-family: MathJax_Math-italic;">d<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-40" style="font-family: MathJax_Math-italic;">t</span><span class="mo" id="MathJax-Span-41" style="font-family: MathJax_Main;">.</span><span class="mi" id="MathJax-Span-42" style="font-family: MathJax_Math-italic; padding-left: 0.163em;">j</span><span class="mi" id="MathJax-Span-43" style="font-family: MathJax_Math-italic;">a</span><span class="mi" id="MathJax-Span-44" style="font-family: MathJax_Math-italic;">r</span><span class="mo" id="MathJax-Span-45" style="font-family: MathJax_Main; padding-left: 0.269em;">:</span></span><span style="display: inline-block; width: 0px; height: 2.723em;"></span></span></span><span style="border-left: 0.003em solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.397em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-2">JAVA_HOME/lib/dt.jar:</script>JAVA_HOME/lib/tools.jar
·重新登录
·注解
a. 你要将 /usr/share/jdk1.6.0_14改为你的jdk安装目录
b. linux下用冒号“:”来分隔路径
c. <nobr><span class="math" id="MathJax-Span-46" style="width: 4.483em; display: inline-block;"><span style="display: inline-block; position: relative; width: 3.576em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.816em 1000em 3.149em -0.424em); top: -2.717em; left: 0.003em;"><span class="mrow" id="MathJax-Span-47"><span class="mi" id="MathJax-Span-48" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mi" id="MathJax-Span-49" style="font-family: MathJax_Math-italic;">A</span><span class="mi" id="MathJax-Span-50" style="font-family: MathJax_Math-italic;">T<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mi" id="MathJax-Span-51" style="font-family: MathJax_Math-italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-52"><span class="mrow" id="MathJax-Span-53"><span class="mo" id="MathJax-Span-54" style="font-family: MathJax_Main;">/</span></span></span></span><span style="display: inline-block; width: 0px; height: 2.723em;"></span></span></span><span style="border-left: 0.003em solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.397em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-3">PATH / </script>CLASSPATH / $JAVA_HOME 是用来引用原来的环境变量的值
在设置环境变量时特别要注意不能把原来的值给覆盖掉了,这是一种
常见的错误。
d. CLASSPATH中当前目录“.”不能丢,把当前目录丢掉也是常见的错误。
e. export是把这三个变量导出为全局变量。
f. 大小写必须严格区分。
- 修改.bash_profile文件
这种方法更为安全,它可以把使用这些环境变量的权限控制到用户级别,如果你需要给某个用户权限使用这些环境变量,你只需要修改其个人用户主目录下的.bash_profile文件就可以了。
·用文本编辑器打开用户目录下的.bash_profile文件
·在.bash_profile文件末尾加入:
export JAVA_HOME=/usr/share/jdk1.6.0_14
export PATH=<nobr><span class="math" id="MathJax-Span-55" style="width: 10.669em; display: inline-block;"><span style="display: inline-block; position: relative; width: 8.536em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.816em 1000em 3.149em -0.424em); top: -2.717em; left: 0.003em;"><span class="mrow" id="MathJax-Span-56"><span class="mi" id="MathJax-Span-57" style="font-family: MathJax_Math-italic;">J<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mi" id="MathJax-Span-58" style="font-family: MathJax_Math-italic;">A</span><span class="mi" id="MathJax-Span-59" style="font-family: MathJax_Math-italic;">V<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.163em;"></span></span><span class="msubsup" id="MathJax-Span-60"><span style="display: inline-block; position: relative; width: 1.443em; height: 0px;"><span style="position: absolute; clip: rect(1.709em 1000em 2.723em -0.424em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-61" style="font-family: MathJax_Math-italic;">A</span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.291em; left: 0.749em;"><span class="mi" id="MathJax-Span-62" style="font-size: 70.7%; font-family: MathJax_Math-italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.456em;"></span></span></span></span><span class="mi" id="MathJax-Span-63" style="font-family: MathJax_Math-italic;">O</span><span class="mi" id="MathJax-Span-64" style="font-family: MathJax_Math-italic;">M<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mi" id="MathJax-Span-65" style="font-family: MathJax_Math-italic;">E<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="texatom" id="MathJax-Span-66"><span class="mrow" id="MathJax-Span-67"><span class="mo" id="MathJax-Span-68" style="font-family: MathJax_Main;">/</span></span></span><span class="mi" id="MathJax-Span-69" style="font-family: MathJax_Math-italic;">b</span><span class="mi" id="MathJax-Span-70" style="font-family: MathJax_Math-italic;">i</span><span class="mi" id="MathJax-Span-71" style="font-family: MathJax_Math-italic;">n</span><span class="mo" id="MathJax-Span-72" style="font-family: MathJax_Main; padding-left: 0.269em;">:</span></span><span style="display: inline-block; width: 0px; height: 2.723em;"></span></span></span><span style="border-left: 0.003em solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.397em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-4">JAVA_HOME/bin:</script>PATH
export CLASSPATH=.:<nobr><span class="math" id="MathJax-Span-73" style="width: 14.349em; display: inline-block;"><span style="display: inline-block; position: relative; width: 11.469em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.816em 1000em 3.149em -0.424em); top: -2.717em; left: 0.003em;"><span class="mrow" id="MathJax-Span-74"><span class="mi" id="MathJax-Span-75" style="font-family: MathJax_Math-italic;">J<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mi" id="MathJax-Span-76" style="font-family: MathJax_Math-italic;">A</span><span class="mi" id="MathJax-Span-77" style="font-family: MathJax_Math-italic;">V<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.163em;"></span></span><span class="msubsup" id="MathJax-Span-78"><span style="display: inline-block; position: relative; width: 1.443em; height: 0px;"><span style="position: absolute; clip: rect(1.709em 1000em 2.723em -0.424em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-79" style="font-family: MathJax_Math-italic;">A</span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.291em; left: 0.749em;"><span class="mi" id="MathJax-Span-80" style="font-size: 70.7%; font-family: MathJax_Math-italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.456em;"></span></span></span></span><span class="mi" id="MathJax-Span-81" style="font-family: MathJax_Math-italic;">O</span><span class="mi" id="MathJax-Span-82" style="font-family: MathJax_Math-italic;">M<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mi" id="MathJax-Span-83" style="font-family: MathJax_Math-italic;">E<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="texatom" id="MathJax-Span-84"><span class="mrow" id="MathJax-Span-85"><span class="mo" id="MathJax-Span-86" style="font-family: MathJax_Main;">/</span></span></span><span class="mi" id="MathJax-Span-87" style="font-family: MathJax_Math-italic;">l</span><span class="mi" id="MathJax-Span-88" style="font-family: MathJax_Math-italic;">i</span><span class="mi" id="MathJax-Span-89" style="font-family: MathJax_Math-italic;">b</span><span class="texatom" id="MathJax-Span-90"><span class="mrow" id="MathJax-Span-91"><span class="mo" id="MathJax-Span-92" style="font-family: MathJax_Main;">/</span></span></span><span class="mi" id="MathJax-Span-93" style="font-family: MathJax_Math-italic;">d<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-94" style="font-family: MathJax_Math-italic;">t</span><span class="mo" id="MathJax-Span-95" style="font-family: MathJax_Main;">.</span><span class="mi" id="MathJax-Span-96" style="font-family: MathJax_Math-italic; padding-left: 0.163em;">j</span><span class="mi" id="MathJax-Span-97" style="font-family: MathJax_Math-italic;">a</span><span class="mi" id="MathJax-Span-98" style="font-family: MathJax_Math-italic;">r</span><span class="mo" id="MathJax-Span-99" style="font-family: MathJax_Main; padding-left: 0.269em;">:</span></span><span style="display: inline-block; width: 0px; height: 2.723em;"></span></span></span><span style="border-left: 0.003em solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.397em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-5">JAVA_HOME/lib/dt.jar:</script>JAVA_HOME/lib/tools.jar
·重新登录
- 直接在shell下设置变量
不赞成使用这种方法,因为换个shell,你的设置就无效了,因此这种方法仅仅是临时使用,以后要使用的时候又要重新设置,比较麻烦。
只需在shell终端执行下列命令:
export JAVA_HOME=/usr/share/jdk1.6.0_14
export PATH=<nobr><span class="math" id="MathJax-Span-100" style="width: 10.669em; display: inline-block;"><span style="display: inline-block; position: relative; width: 8.536em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.816em 1000em 3.149em -0.424em); top: -2.717em; left: 0.003em;"><span class="mrow" id="MathJax-Span-101"><span class="mi" id="MathJax-Span-102" style="font-family: MathJax_Math-italic;">J<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mi" id="MathJax-Span-103" style="font-family: MathJax_Math-italic;">A</span><span class="mi" id="MathJax-Span-104" style="font-family: MathJax_Math-italic;">V<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.163em;"></span></span><span class="msubsup" id="MathJax-Span-105"><span style="display: inline-block; position: relative; width: 1.443em; height: 0px;"><span style="position: absolute; clip: rect(1.709em 1000em 2.723em -0.424em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-106" style="font-family: MathJax_Math-italic;">A</span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.291em; left: 0.749em;"><span class="mi" id="MathJax-Span-107" style="font-size: 70.7%; font-family: MathJax_Math-italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.456em;"></span></span></span></span><span class="mi" id="MathJax-Span-108" style="font-family: MathJax_Math-italic;">O</span><span class="mi" id="MathJax-Span-109" style="font-family: MathJax_Math-italic;">M<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mi" id="MathJax-Span-110" style="font-family: MathJax_Math-italic;">E<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="texatom" id="MathJax-Span-111"><span class="mrow" id="MathJax-Span-112"><span class="mo" id="MathJax-Span-113" style="font-family: MathJax_Main;">/</span></span></span><span class="mi" id="MathJax-Span-114" style="font-family: MathJax_Math-italic;">b</span><span class="mi" id="MathJax-Span-115" style="font-family: MathJax_Math-italic;">i</span><span class="mi" id="MathJax-Span-116" style="font-family: MathJax_Math-italic;">n</span><span class="mo" id="MathJax-Span-117" style="font-family: MathJax_Main; padding-left: 0.269em;">:</span></span><span style="display: inline-block; width: 0px; height: 2.723em;"></span></span></span><span style="border-left: 0.003em solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.397em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-6">JAVA_HOME/bin:</script>PATH
export CLASSPATH=.:<nobr><span class="math" id="MathJax-Span-118" style="width: 14.349em; display: inline-block;"><span style="display: inline-block; position: relative; width: 11.469em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.816em 1000em 3.149em -0.424em); top: -2.717em; left: 0.003em;"><span class="mrow" id="MathJax-Span-119"><span class="mi" id="MathJax-Span-120" style="font-family: MathJax_Math-italic;">J<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mi" id="MathJax-Span-121" style="font-family: MathJax_Math-italic;">A</span><span class="mi" id="MathJax-Span-122" style="font-family: MathJax_Math-italic;">V<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.163em;"></span></span><span class="msubsup" id="MathJax-Span-123"><span style="display: inline-block; position: relative; width: 1.443em; height: 0px;"><span style="position: absolute; clip: rect(1.709em 1000em 2.723em -0.424em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-124" style="font-family: MathJax_Math-italic;">A</span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.291em; left: 0.749em;"><span class="mi" id="MathJax-Span-125" style="font-size: 70.7%; font-family: MathJax_Math-italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.456em;"></span></span></span></span><span class="mi" id="MathJax-Span-126" style="font-family: MathJax_Math-italic;">O</span><span class="mi" id="MathJax-Span-127" style="font-family: MathJax_Math-italic;">M<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mi" id="MathJax-Span-128" style="font-family: MathJax_Math-italic;">E<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="texatom" id="MathJax-Span-129"><span class="mrow" id="MathJax-Span-130"><span class="mo" id="MathJax-Span-131" style="font-family: MathJax_Main;">/</span></span></span><span class="mi" id="MathJax-Span-132" style="font-family: MathJax_Math-italic;">l</span><span class="mi" id="MathJax-Span-133" style="font-family: MathJax_Math-italic;">i</span><span class="mi" id="MathJax-Span-134" style="font-family: MathJax_Math-italic;">b</span><span class="texatom" id="MathJax-Span-135"><span class="mrow" id="MathJax-Span-136"><span class="mo" id="MathJax-Span-137" style="font-family: MathJax_Main;">/</span></span></span><span class="mi" id="MathJax-Span-138" style="font-family: MathJax_Math-italic;">d<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-139" style="font-family: MathJax_Math-italic;">t</span><span class="mo" id="MathJax-Span-140" style="font-family: MathJax_Main;">.</span><span class="mi" id="MathJax-Span-141" style="font-family: MathJax_Math-italic; padding-left: 0.163em;">j</span><span class="mi" id="MathJax-Span-142" style="font-family: MathJax_Math-italic;">a</span><span class="mi" id="MathJax-Span-143" style="font-family: MathJax_Math-italic;">r</span><span class="mo" id="MathJax-Span-144" style="font-family: MathJax_Main; padding-left: 0.269em;">:</span></span><span style="display: inline-block; width: 0px; height: 2.723em;"></span></span></span><span style="border-left: 0.003em solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.397em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-7">JAVA_HOME/lib/dt.jar:</script>JAVA_HOME/lib/tools.jar
四. 测试jdk
1. 用文本编辑器新建一个Test.java文件,在其中输入以下代码并保存:
public class test {
public static void main(String args[]) {
System.out.println(“A new jdk test !”);
}
}
2. 编译:在shell终端执行命令 javac Test.java
3. 运行:在shell终端执行命令 java Test
当shell下出现“A new jdk test !”字样则jdk运行正常。
五. 卸载jdk
·找到jdk安装目录的_uninst子目录
·在shell终端执行命令./uninstall.sh即可卸载jdk。
Desire has no rest.
摘自
更多推荐
所有评论(0)