Java Nio 简明教程

Java NIO - Environment Setup

本部分指导您如何在计算机上下载和设置 Java。请按照以下步骤设置环境。

This section guides you on how to download and set up Java on your machine. Please follow the following steps to set up the environment.

Java SE 可以从链接 Download Java 中免费获取。因此,您可以根据自己的操作系统下载版本。

Java SE is freely available from the link Download Java. So you download a version based on your operating system.

按照说明下载 Java 并运行 .exe 在您的机器上安装 Java。在计算机上安装 Java 后,您需要设置环境变量以指向正确的安装目录 −

Follow the instructions to download java and run the .exe to install Java on your machine. Once you installed Java on your machine, you would need to set environment variables to point to correct installation directories −

Setting up the path for windows 2000/XP

假设你已将 Java 安装在 c:\Program Files\java\jdk 目录中 −

Assuming you have installed Java in c:\Program Files\java\jdk directory −

  1. Right-click on 'My Computer' and select 'Properties'.

  2. Click on the 'Environment variables' button under the 'Advanced' tab.

  3. Now alter the 'Path' variable so that it also contains the path to the Java executable. Example, if the path is currently set to 'C:\WINDOWS\SYSTEM32', then change your path to read 'C:\WINDOWS\SYSTEM32;c:\Program Files\java\jdk\bin'.

Setting up the path for windows 95/98/ME

假设你已将 Java 安装在 c:\Program Files\java\jdk 目录中 −

Assuming you have installed Java in c:\Program Files\java\jdk directory −

  1. Edit the 'C:\autoexec.bat' file and add the following line at the end: 'SET PATH = %PATH%;C:\Program Files\java\jdk\bin'

Setting up the path for Linux, UNIX, Solaris, FreeBSD

环境变量 PATH 应设置为指向已安装 Java 二进制文件的位置。如果您在执行此操作时遇到问题,请参阅您的 shell 文档。

Environment variable PATH should be set to point to where the java binaries have been installed. Refer to your shell documentation if you have trouble doing this.

例如,如果您使用 bash 作为您的 shell,那么您将向 '.bashrc 的尾部添加以下行: export PATH = /path/to/java:$PATH'

Example, if you use bash as your shell, then you would add the following line to the end of your '.bashrc: export PATH = /path/to/java:$PATH'

要编写 Java 程序,您需要一个文本编辑器。市场上还有更多高级的 IDE 可用。但现在,您可以考虑以下选项之一 −

To write your java programs you will need a text editor. There are even more sophisticated IDE available in the market. But for now, you can consider one of the following −

  1. Notepad − On Windows machine you can use any simple text editor like Notepad (Recommended for this tutorial), TextPad.

  2. Netbeans − is a Java IDE that is open source and free which can be downloaded from http://www.netbeans.org/index.html.

  3. Eclipse − is also a java IDE developed by the eclipse open source community and can be downloaded from https://www.eclipse.org/.