Java Generics 简明教程

Java Generics - Environment Setup

Local Environment Setup

JUnit 是 Java 框架,因此最先决条件是在您的计算机中安装 JDK。

JUnit is a framework for Java, so the very first requirement is to have JDK installed in your machine.

System Requirement

JDK

1.5 or above.

Memory

No minimum requirement.

Disk Space

No minimum requirement.

Operating System

No minimum requirement.

Step 1: Verify Java Installation in Your Machine

首先,打开控制台并根据您正在使用的操作系统执行 java 命令。

First of all, open the console and execute a java command based on the operating system you are working on.

OS

Task

Command

Windows

Open Command Console

c:> java -version

Linux

Open Command Terminal

$ java -version

Mac

Open Terminal

machine:< joseph$ java -version

让我们验证所有操作系统的输出 −

Let’s verify the output for all the operating systems −

OS

Output

Windows

java version "1.6.0_21" Java™ SE Runtime Environment (build 1.6.0_21-b07) Java HotSpot™ Client VM (build 17.0-b17, mixed mode, sharing)

Linux

java version "1.6.0_21" Java™ SE Runtime Environment (build 1.6.0_21-b07) Java HotSpot™ Client VM (build 17.0-b17, mixed mode, sharing)

Mac

java version "1.6.0_21" Java™ SE Runtime Environment (build 1.6.0_21-b07) Java HotSpot™64-Bit Server VM (build 17.0-b17, mixed mode, sharing)

如果您的系统上没有安装 Java,请从以下链接下载 Java 软件开发工具包 (SDK): https://www.oracle.com 。本教程假设已安装 Java 1.6.0_21 版本。

If you do not have Java installed on your system, then download the Java Software Development Kit (SDK) from the following link https://www.oracle.com. We are assuming Java 1.6.0_21 as the installed version for this tutorial.

Step 2: Set JAVA Environment

JAVA_HOME 环境变量设置为您计算机中安装 Java 的基本目录位置。例如。

Set the JAVA_HOME environment variable to point to the base directory location where Java is installed on your machine. For example.

OS

Output

Windows

Set the environment variable JAVA_HOME to C:\Program Files\Java\jdk1.6.0_21

Linux

export JAVA_HOME = /usr/local/java-current

Mac

export JAVA_HOME = /Library/Java/Home

在系统路径中追加 Java 编译器位置。

Append Java compiler location to the System Path.

OS

Output

Windows

Append the string C:\Program Files\Java\jdk1.6.0_21\bin at the end of the system variable, Path.

Linux

export PATH = $PATH:$JAVA_HOME/bin/

Mac

not required

如上所述,使用命令 java -version 验证 Java 安装。

Verify Java installation using the command java -version as explained above.