【Jdk】32位redhat6系统安装jdk

1.所需环境准备



需求


备注


操作系统


Red Hat Linux Server 6(32位)
          JDK安装包                                      jdk-6u20-linux-i586.bin

2.开始安装


a.使用root用户将jdk1.6安装包上传至linux服务器上的/app/install目录下,并使用root用户登录上述服务器进行如下安装操作

b.修改jdk的权限,执行以下命令


1. <span class="pln">chmod </span><span class="lit">755</span><span class="pln"> jdk</span><span class="pun">-</span><span class="lit">6u20</span><span class="pun">-</span><span class="pln">linux</span><span class="pun">-</span><span class="pln">i586</span><span class="pun">.</span><span class="pln">bin</span>
c.准备工作完成后开始安装.执行


1. <span class="pun">./</span><span class="pln">jdk</span><span class="pun">-</span><span class="lit">6u20</span><span class="pun">-</span><span class="pln">linux</span><span class="pun">-</span><span class="pln">i586</span><span class="pun">.</span><span class="pln">bin</span>
d.   界面首先提示 


1. <span class="typ">Sun</span><span class="pln"> </span><span class="typ">Microsystems</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Inc</span><span class="pun">.</span><span class="pln"> </span><span class="typ">Binary</span><span class="pln"> </span><span class="typ">Code</span><span class="pln"> </span><span class="typ">License</span><span class="pln"> </span><span class="typ">Agreement</span><span class="pln"> </span>
2. <span class="kwd">for</span><span class="pln"> the JAVA SE DEVELOPMENT KIT </span><span class="pun">(</span><span class="pln">JDK</span><span class="pun">),</span><span class="pln"> VERSION </span><span class="lit">6</span><span class="pln"> </span>
3. <span class="pun">……</span><span class="pln"> </span>
4. <span class="pun">会提示“</span><span class="pln"> </span><span class="pun">--</span><span class="typ">More</span><span class="pun">--</span><span class="pln"> </span><span class="pun">”,按空格键翻页</span><span class="pln"> </span>

e.输入“ yes ”确认同意; 


1. <span class="typ">Do</span><span class="pln"> you agree to the above license terms</span><span class="pun">?</span><span class="pln"> </span><span class="pun">[</span><span class="pln">yes or no</span><span class="pun">]</span><span class="pln"> </span>
2. <span class="pln">yes </span>
3. <span class="pun">安装程序自动解压缩安装,直至提示安装成功</span><span class="pln"> </span><span class="pun">;按回车键(</span><span class="pln"> </span><span class="typ">Enter</span><span class="pln"> </span><span class="pun">)完成安装;</span>
3.配置环境变量


#vi ~/.bash_profile

i键,进入编辑模式,在最后面加入 JDK环境变量(JAVA_HOME的地址按实际jdk配置)

 C:\Users\ADMINI~1\AppData\Local\Temp\ksohtml\wps_clip_image7.png

ESC键,退出编辑模式,输入命令:wq保存退出。

# . /etc/profile
注意: . 和 /etc/profile 有空格.


4.检验JDK是否安装成功

     重新启动系统或者注销当前用户 打开客户端执行javac


1. <span class="pun">[</span><span class="pln">root@localhost </span><span class="typ">Desktop</span><span class="pun">]#</span><span class="pln"> javac</span>
2. <span class="typ">Usage</span><span class="pun">:</span><span class="pln"> javac </span><span class="pun">&lt;</span><span class="pln">options</span><span class="pun">&gt;</span><span class="pln"> </span><span class="pun">&lt;</span><span class="pln">source files</span><span class="pun">&gt;</span>
3. <span class="pln">where possible options include</span><span class="pun">:</span>
4. <span class="pln"> </span><span class="pun">-</span><span class="pln">g </span><span class="typ">Generate</span><span class="pln"> all debugging info</span>
5. <span class="pln"> </span><span class="pun">-</span><span class="pln">g</span><span class="pun">:</span><span class="pln">none </span><span class="typ">Generate</span><span class="pln"> no debugging info</span>
6. <span class="pln"> </span><span class="pun">-</span><span class="pln">g</span><span class="pun">:{</span><span class="pln">lines</span><span class="pun">,</span><span class="pln">vars</span><span class="pun">,</span><span class="pln">source</span><span class="pun">}</span><span class="pln"> </span><span class="typ">Generate</span><span class="pln"> only some debugging info</span>
7. <span class="pln"> </span><span class="pun">-</span><span class="pln">nowarn </span><span class="typ">Generate</span><span class="pln"> no warnings</span>
8. <span class="pln"> </span><span class="pun">-</span><span class="pln">verbose </span><span class="typ">Output</span><span class="pln"> messages about what the compiler is doing</span>
9. <span class="pln"> </span><span class="pun">-</span><span class="pln">deprecation </span><span class="typ">Output</span><span class="pln"> source locations where deprecated </span><span class="typ">APIs</span><span class="pln"> are used</span>
10. <span class="pln"> </span><span class="pun">-</span><span class="pln">classpath </span><span class="pun">&lt;</span><span class="pln">path</span><span class="pun">&gt;</span><span class="pln"> </span><span class="typ">Specify</span><span class="pln"> where to find user class files and annotation processors</span>
11. <span class="pln"> </span><span class="pun">-</span><span class="pln">cp </span><span class="pun">&lt;</span><span class="pln">path</span><span class="pun">&gt;</span><span class="pln"> </span><span class="typ">Specify</span><span class="pln"> where to find user class files and annotation processors</span>
12. <span class="pln"> </span><span class="pun">-</span><span class="pln">sourcepath </span><span class="pun">&lt;</span><span class="pln">path</span><span class="pun">&gt;</span><span class="pln"> </span><span class="typ">Specify</span><span class="pln"> where to find input source files</span>
13. <span class="pln"> </span><span class="pun">-</span><span class="pln">bootclasspath </span><span class="pun">&lt;</span><span class="pln">path</span><span class="pun">&gt;</span><span class="pln"> </span><span class="typ">Override</span><span class="pln"> location of bootstrap class files</span>
14. <span class="pln"> </span><span class="pun">-</span><span class="pln">extdirs </span><span class="pun">&lt;</span><span class="pln">dirs</span><span class="pun">&gt;</span><span class="pln"> </span><span class="typ">Override</span><span class="pln"> location of installed extensions</span>
15. <span class="pln"> </span><span class="pun">-</span><span class="pln">endorseddirs </span><span class="pun">&lt;</span><span class="pln">dirs</span><span class="pun">&gt;</span><span class="pln"> </span><span class="typ">Override</span><span class="pln"> location of endorsed standards path</span>
16. <span class="pln"> </span><span class="pun">-</span><span class="pln">proc</span><span class="pun">:{</span><span class="pln">none</span><span class="pun">,</span><span class="pln">only</span><span class="pun">}</span><span class="pln"> </span><span class="typ">Control</span><span class="pln"> whether annotation processing and</span><span class="pun">/</span><span class="pln">or compilation is </span><span class="kwd">done</span><span class="pun">.</span>
17. <span class="pln"> </span><span class="pun">-</span><span class="pln">processor </span><span class="pun">&lt;</span><span class="pln">class1</span><span class="pun">&gt;[,&lt;</span><span class="pln">class2</span><span class="pun">&gt;,&lt;</span><span class="pln">class3</span><span class="pun">&gt;...]</span><span class="typ">Names</span><span class="pln"> of the annotation processors to run</span><span class="pun">;</span><span class="pln"> bypasses default discovery process</span>
18. <span class="pln"> </span><span class="pun">-</span><span class="pln">processorpath </span><span class="pun">&lt;</span><span class="pln">path</span><span class="pun">&gt;</span><span class="pln"> </span><span class="typ">Specify</span><span class="pln"> where to find annotation processors</span>
19. <span class="pln"> </span><span class="pun">-</span><span class="pln">d </span><span class="pun">&lt;</span><span class="pln">directory</span><span class="pun">&gt;</span><span class="pln"> </span><span class="typ">Specify</span><span class="pln"> where to place generated class files</span>
20. <span class="pln"> </span><span class="pun">-</span><span class="pln">s </span><span class="pun">&lt;</span><span class="pln">directory</span><span class="pun">&gt;</span><span class="pln"> </span><span class="typ">Specify</span><span class="pln"> where to place generated source files</span>
21. <span class="pln"> </span><span class="pun">-</span><span class="pln">implicit</span><span class="pun">:{</span><span class="pln">none</span><span class="pun">,</span><span class="pln">class</span><span class="pun">}</span><span class="pln"> </span><span class="typ">Specify</span><span class="pln"> whether or not to generate class files </span><span class="kwd">for</span><span class="pln"> implicitly referenced files </span>
22. <span class="pln"> </span><span class="pun">-</span><span class="pln">encoding </span><span class="pun">&lt;</span><span class="pln">encoding</span><span class="pun">&gt;</span><span class="pln"> </span><span class="typ">Specify</span><span class="pln"> character encoding used by source files</span>
23. <span class="pln"> </span><span class="pun">-</span><span class="pln">source </span><span class="pun">&lt;</span><span class="pln">release</span><span class="pun">&gt;</span><span class="pln"> </span><span class="typ">Provide</span><span class="pln"> source compatibility with specified release</span>
24. <span class="pln"> </span><span class="pun">-</span><span class="pln">target </span><span class="pun">&lt;</span><span class="pln">release</span><span class="pun">&gt;</span><span class="pln"> </span><span class="typ">Generate</span><span class="pln"> class files </span><span class="kwd">for</span><span class="pln"> specific VM version</span>
25. <span class="pln"> </span><span class="pun">-</span><span class="pln">version </span><span class="typ">Version</span><span class="pln"> information</span>
26. <span class="pln"> </span><span class="pun">-</span><span class="pln">help </span><span class="typ">Print</span><span class="pln"> a synopsis of standard options</span>
27. <span class="pln"> </span><span class="pun">-</span><span class="typ">Akey</span><span class="pun">[=</span><span class="pln">value</span><span class="pun">]</span><span class="pln"> </span><span class="typ">Options</span><span class="pln"> to pass to annotation processors</span>
28. <span class="pln"> </span><span class="pun">-</span><span class="pln">X </span><span class="typ">Print</span><span class="pln"> a synopsis of nonstandard options</span>
29. <span class="pln"> </span><span class="pun">-</span><span class="pln">J</span><span class="pun">&lt;</span><span class="pln">flag</span><span class="pun">&gt;</span><span class="pln"> </span><span class="typ">Pass</span><span class="pln"> </span><span class="pun">&lt;</span><span class="pln">flag</span><span class="pun">&gt;</span><span class="pln"> directly to the runtime system</span>

执行 java -version,如果看到JVM版本及相关信息,即安装成功



1. <span class="pun">[</span><span class="pln">root@localhost </span><span class="typ">Desktop</span><span class="pun">]#</span><span class="pln"> java </span><span class="pun">-</span><span class="pln">version</span>
2. <span class="pln">java version </span><span class="str">"1.6.0_20"</span>
3. <span class="typ">Java</span><span class="pun">(</span><span class="pln">TM</span><span class="pun">)</span><span class="pln"> SE </span><span class="typ">Runtime</span><span class="pln"> </span><span class="typ">Environment</span><span class="pln"> </span><span class="pun">(</span><span class="pln">build </span><span class="lit">1.6</span><span class="pun">.</span><span class="lit">0_20</span><span class="pun">-</span><span class="pln">b02</span><span class="pun">)</span>
4. <span class="typ">Java</span><span class="pln"> </span><span class="typ">HotSpot</span><span class="pun">(</span><span class="pln">TM</span><span class="pun">)</span><span class="pln"> </span><span class="typ">Server</span><span class="pln"> VM </span><span class="pun">(</span><span class="pln">build </span><span class="lit">16.3</span><span class="pun">-</span><span class="pln">b01</span><span class="pun">,</span><span class="pln"> mixed mode</span><span class="pun">)</span>

5.常见问题分析

  1.解决在root中配置JDK其他用户不生效,当时设置时用的命令是


1. <span class="pln">vi </span><span class="pun">~/.</span><span class="pln">bash_profile</span>
原因分析,~/此时是指当前目录,此句话的意思是配置了root用户的环境变量文件,对于其他文件会因为权限问题导致问题
解决环境变量配置到全局变量中


1. <span class="pln">vi </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">profile</span>
profile是系统文件,对系统下全体用户起作用

 


 









your support will encourage me to continue to create!
版权声明:自由转载-非商用-非衍生-保持署名(创意共享3.0许可证)