`
xiaoer_1982
  • 浏览: 1815216 次
  • 性别: Icon_minigender_2
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

Java实例教程(1)JDK的获取、安装与配置

阅读更多

声明:本系列教程为本人目前编写的一部教材,请勿擅自转载。

如需使用请联系本人:lilizong【at】gmail.com

因图片较多,未将图片一一展示!

<!-- [if supportFields]><span lang=EN-US><span style="mso-element:field-begin" mce_style="mso-element:field-begin"></span><span style='mso-spacerun:yes'>&nbsp;</span>TOC \o &quot;1-3&quot; \h \z \u <span style='mso-element:field-separator'></span></span><![endif]-->教程 1 JDK的获取、安装与配置 .... <!-- [if supportFields]><span style='color:windowtext;display:none;mso-hide:screen;text-decoration:none; text-underline:none'><span style="mso-element:field-begin" mce_style="mso-element:field-begin"></span></span><span style='color:windowtext;display:none;mso-hide:screen;text-decoration:none; text-underline:none'> PAGEREF _Toc225090863 \h </span><span style="color:windowtext; display:none;mso-hide:screen;text-decoration:none;text-underline:none" mce_style="color:windowtext; display:none;mso-hide:screen;text-decoration:none;text-underline:none"><span style='mso-element:field-separator'></span></span><![endif]-->1 <!-- [if gte mso 9]><xml> <w:data>08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003200320035003000390030003800360033000000</w:data> </xml><![endif]--> <!-- [if supportFields]><span style="color:windowtext; display:none;mso-hide:screen;text-decoration:none;text-underline:none" mce_style="color:windowtext; display:none;mso-hide:screen;text-decoration:none;text-underline:none"><span style='mso-element:field-end'></span></span><![endif]-->

1.1 JDK的获取 ... <!-- [if supportFields]><span style='color:windowtext;display:none;mso-hide:screen;text-decoration:none; text-underline:none'><span style="mso-element:field-begin" mce_style="mso-element:field-begin"></span></span><span style='color:windowtext;display:none;mso-hide:screen;text-decoration:none; text-underline:none'> PAGEREF _Toc225090864 \h </span><span style="color:windowtext; display:none;mso-hide:screen;text-decoration:none;text-underline:none" mce_style="color:windowtext; display:none;mso-hide:screen;text-decoration:none;text-underline:none"><span style='mso-element:field-separator'></span></span><![endif]-->1 <!-- [if gte mso 9]><xml> <w:data>08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003200320035003000390030003800360034000000</w:data> </xml><![endif]--> <!-- [if supportFields]><span style="color:windowtext; display:none;mso-hide:screen;text-decoration:none;text-underline:none" mce_style="color:windowtext; display:none;mso-hide:screen;text-decoration:none;text-underline:none"><span style='mso-element:field-end'></span></span><![endif]-->

1.2 JDK的安装 ... <!-- [if supportFields]><span style='color:windowtext;display:none;mso-hide:screen;text-decoration:none; text-underline:none'><span style="mso-element:field-begin" mce_style="mso-element:field-begin"></span></span><span style='color:windowtext;display:none;mso-hide:screen;text-decoration:none; text-underline:none'> PAGEREF _Toc225090865 \h </span><span style="color:windowtext; display:none;mso-hide:screen;text-decoration:none;text-underline:none" mce_style="color:windowtext; display:none;mso-hide:screen;text-decoration:none;text-underline:none"><span style='mso-element:field-separator'></span></span><![endif]-->2 <!-- [if gte mso 9]><xml> <w:data>08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003200320035003000390030003800360035000000</w:data> </xml><![endif]--> <!-- [if supportFields]><span style="color:windowtext; display:none;mso-hide:screen;text-decoration:none;text-underline:none" mce_style="color:windowtext; display:none;mso-hide:screen;text-decoration:none;text-underline:none"><span style='mso-element:field-end'></span></span><![endif]-->

1.3 JDK的配置 ... <!-- [if supportFields]><span style='color:windowtext;display:none;mso-hide:screen;text-decoration:none; text-underline:none'><span style="mso-element:field-begin" mce_style="mso-element:field-begin"></span></span><span style='color:windowtext;display:none;mso-hide:screen;text-decoration:none; text-underline:none'> PAGEREF _Toc225090866 \h </span><span style="color:windowtext; display:none;mso-hide:screen;text-decoration:none;text-underline:none" mce_style="color:windowtext; display:none;mso-hide:screen;text-decoration:none;text-underline:none"><span style='mso-element:field-separator'></span></span><![endif]-->6 <!-- [if gte mso 9]><xml> <w:data>08D0C9EA79F9BACE118C8200AA004BA90B02000000080000000E0000005F0054006F0063003200320035003000390030003800360036000000</w:data> </xml><![endif]--> <!-- [if supportFields]><span style="color:windowtext; display:none;mso-hide:screen;text-decoration:none;text-underline:none" mce_style="color:windowtext; display:none;mso-hide:screen;text-decoration:none;text-underline:none"><span style='mso-element:field-end'></span></span><![endif]-->

<!-- [if supportFields]><span lang=EN-US><span style='mso-element:field-end'></span></span><![endif]-->

教程 1 JDK 的获取、安装与配置

教学目标

在本教程中,读者将学到以下内容:

<!-- [if !supportLists]-->l <!-- [endif]-->JDK 的安装

<!-- [if !supportLists]-->l <!-- [endif]-->JDK 的配置

1.1 JDK 的获取

1 JDK 的最新版本是 JDK6.0 ,可以从 Sun 公司的官方网站: http://java.sun.com 中下载,具体地址为: http://java.sun.com/javase/downloads/index.jsp ,下载页面如图 1.1 所示。

<!-- [if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter"/> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"/> <v:f eqn="sum @0 1 0"/> <v:f eqn="sum 0 0 @1"/> <v:f eqn="prod @2 1 2"/> <v:f eqn="prod @3 21600 pixelWidth"/> <v:f eqn="prod @3 21600 pixelHeight"/> <v:f eqn="sum @0 0 1"/> <v:f eqn="prod @6 1 2"/> <v:f eqn="prod @7 21600 pixelWidth"/> <v:f eqn="sum @8 21600 0"/> <v:f eqn="prod @7 21600 pixelHeight"/> <v:f eqn="sum @10 21600 0"/> </v:formulas> <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/> <o:lock v:ext="edit" aspectratio="t"/> </v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" style='width:414.75pt; height:211.5pt'> <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image001.png" mce_src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image001.png" o:title="1"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

1.1 JDK6.0 下载页面 1

2 单击图 1.1 中的“ Download ”按钮,进入如图 1.2 所示页面。在该页面内选择“ Platform ”为“ Windows ”,“ Language ”为“ Multi-language ”,同时选择接受协议。

<!-- [if gte vml 1]><v:shape id="_x0000_i1026" type="#_x0000_t75" style='width:397.5pt;height:245.25pt'> <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image003.png" mce_src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image003.png" o:title="2"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

1.2 JDK6.0 下载页面 2

3 在图 1.2 中选择“ Continue ”进入如图 1.3 所示下载页面。

<!-- [if gte vml 1]><v:shape id="_x0000_i1027" type="#_x0000_t75" style='width:396pt;height:190.5pt'> <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image005.png" mce_src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image005.png" o:title="3"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

1.3 JDK6.0 下载页面 3

4 在图 1.3 内选择“ jdk-6u11-windows-i586-p.exe ”,将文件保存。

1.2 JDK 的安装

1 找到刚刚下载的安装文件,双击该文件,出现如图 1.4 所示对话框。

<!-- [if gte vml 1]><v:shape id="_x0000_i1028" type="#_x0000_t75" style='width:378pt;height:289.5pt'> <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image007.png" mce_src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image007.png" o:title="4"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

1.4 安装界面

2 1.4 出现几秒钟后,出现如图 1.5 所示许可证协议对话框。

<!-- [if gte vml 1]><v:shape id="_x0000_i1029" type="#_x0000_t75" style='width:378pt;height:289.5pt'> <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image009.png" mce_src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image009.png" o:title="5"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

1.5 许可证协议

3 单击“接受”命令按钮,出现如图 1.6 所示自定义安装对话框。

<!-- [if gte vml 1]><v:shape id="_x0000_i1030" type="#_x0000_t75" style='width:378pt;height:289.5pt'> <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image011.png" mce_src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image011.png" o:title="6"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

1.6 自定义安装对话框

4 在图 1.6 中单击“下一步”命令按钮,出现如图 1.7 所示安装进度对话框。

<!-- [if gte vml 1]><v:shape id="_x0000_i1031" type="#_x0000_t75" style='width:378pt;height:289.5pt'> <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image013.png" mce_src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image013.png" o:title="7"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

1.7 安装进度对话框

5 1.7 持续几秒种后,出现如图 1.8 所示目标文件夹对话框。如果需要更改安装路径,单击“更改”命令按钮更改安装路径。

<!-- [if gte vml 1]><v:shape id="_x0000_i1036" type="#_x0000_t75" style='width:378pt;height:289.5pt'> <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image015.png" mce_src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image015.png" o:title="8"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

1.8 目标文件夹对话框

6 在图 1.8 中单击“下一步”命令按钮,出现如图 1.9 所示安装进度对话框。

<!-- [if gte vml 1]><v:shape id="_x0000_i1032" type="#_x0000_t75" style='width:378pt;height:289.5pt'> <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image017.png" mce_src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image017.png" o:title="9"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

1.9 安装进度对话框

7 在图 1.9 持续几秒后,出现如图 1.10 所示安装完成对话框。

<!-- [if gte vml 1]><v:shape id="_x0000_i1033" type="#_x0000_t75" style='width:378pt;height:289.5pt'> <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image019.png" mce_src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image019.png" o:title="10"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

1.10 安装完成对话框

1.3 JDK 的配置

在安装好 JDK 后,需要对系统的环境变量进行一些必要的配置后才可以进行使用。

1 右击“我的电脑”图标,在弹出的快捷菜单中选择“属性”命令,打开“系统属性”对话框,选择“高级”选项卡,如图 1.11 所示。

<!-- [if gte vml 1]><v:shape id="_x0000_i1037" type="#_x0000_t75" style='width:188.25pt;height:224.25pt'> <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image021.png" mce_src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image021.png" o:title="11"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

1.11 系统属性对话框

2 单击“环境变量”命令按钮,打开环境变量对话框,如图 1.12 所示。

<!-- [if gte vml 1]><v:shape id="_x0000_i1038" type="#_x0000_t75" style='width:4in;height:322.5pt'> <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image023.png" mce_src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image023.png" o:title="12"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

1.12 环境变量对话框

3 新建 JAVA_HOME 变量。

单击“系统变量”选项组中的“新建”命令按钮,弹出“编辑系统变量”对话框。在“变量名”内输入“ JAVA_HOME ”,在“变量值”内输入 JDK 的安装路径“ C:\Program Files\Java\jdk1.6.0_11 ”,如图 1.13 所示。完成上述输入后单击“确定”命令按钮。

<!-- [if gte vml 1]><v:shape id="_x0000_i1039" type="#_x0000_t75" style='width:260.25pt;height:104.25pt'> <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image025.png" mce_src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image025.png" o:title="13"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

1.13 新建环境变量对话框

4 编辑 PATH 变量

在“系统变量”选项组中找到“ PATH ”变量并双击,在弹出的“编辑系统变量”对话框中的“变量值”栏中加上“ %JAVA_HOME%\bin ”,如图 1.14 所示。修改完成后单击“确定”完成编辑。

<!-- [if gte vml 1]><v:shape id="_x0000_i1040" type="#_x0000_t75" style='width:260.25pt;height:104.25pt'> <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image027.png" mce_src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image027.png" o:title="14"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

1.14 便就系统变量

5 新建 CLASSPATH 变量

在“系统变量”选项组中单击“新建”按钮,将弹出“新建系统变量”对话框。在其“变量名”栏中输入“ CLASSPATH ”,“变量值”栏中输入“ .;%JAVA_HOME%\lib\rt.jar;%JAVA_HOME%\lib\tools.jar ”,如图 1.15 所示。完成上述操作后,单击“确定”命令按钮完成新建变量。

<!-- [if gte vml 1]><v:shape id="_x0000_i1041" type="#_x0000_t75" style='width:260.25pt;height:104.25pt'> <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image029.png" mce_src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image029.png" o:title="15"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

1.15 新建系统变量

6 单击“开始”菜单中的“所有程序”选项,在弹出的快捷菜单中依次选择“附件”、“命令提示符”后将弹出命令提示符窗口。输入“ java -version ”命令后按回车键,如果安装成功,命令提示符界面窗口如图 1.16 所示。

<!-- [if gte vml 1]><v:shape id="_x0000_i1034" type="#_x0000_t75" style='width:405.75pt;height:113.25pt'> <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image031.gif" mce_src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image031.gif" o:title="16"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

1.16 命令提示符窗口 1

7 在上述命令提示符窗口中输入“ javac –version ”后按回车键,如果安装成功,命令提示符界面窗口如图 1.17 所示。

<!-- [if gte vml 1]><v:shape id="_x0000_i1035" type="#_x0000_t75" style='width:405.75pt;height:101.25pt'> <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image032.gif" mce_src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image032.gif" o:title="17"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

1.17 命令提示符窗口 2

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics