百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 软件资讯 > 正文

第一课:Java简介与开发环境搭建(java开发环境搭建步骤.pdf)

ninehua 2025-04-08 17:02 39 浏览

1. Java简介

**1. Introduction to Java**

Java是一种广泛使用的高级编程语言,由Sun Microsystems(现为Oracle Corporation)于1995年发布。Java具有以下特点:

Java is a widely used high-level programming language, released by Sun Microsystems (now Oracle Corporation) in 1995. Java has the following characteristics:

- **跨平台性**:Java程序可以在任何支持Java虚拟机(JVM)的平台上运行。

**Platform Independence**: Java programs can run on any platform that supports the Java Virtual Machine (JVM).

- **面向对象**:Java是一种面向对象的编程语言,支持封装、继承和多态等特性。

**Object-Oriented**: Java is an object-oriented programming language that supports features such as encapsulation, inheritance, and polymorphism.

- **简单易学**:Java的语法相对简单,适合初学者学习。

**Easy to Learn**: Java's syntax is relatively simple, making it suitable for beginners.


---


#### 2. 开发环境搭建

**2. Setting Up the Development Environment**

要开始编写和运行Java程序,你需要安装以下工具:

To start writing and running Java programs, you need to install the following tools:

- **Java Development Kit (JDK)**:JDK包含了编译和运行Java程序所需的工具。

**Java Development Kit (JDK)**: The JDK contains the tools needed to compile and run Java programs.

- **集成开发环境 (IDE)**:推荐使用IntelliJ IDEA、Eclipse或NetBeans等IDE来编写和调试Java代码。

**Integrated Development Environment (IDE)**: It is recommended to use IDEs such as IntelliJ IDEA, Eclipse, or NetBeans to write and debug Java code.


##### 安装步骤:

**Installation Steps:**

1. **下载并安装JDK**:

**Download and Install JDK:**

- 访问[Oracle官网](
https://www.oracle.com/java/technologies/javase-downloads.html)下载适合你操作系统的JDK版本。

Visit the [Oracle website](https://www.oracle.com/java/technologies/javase-downloads.html) to download the JDK version suitable for your operating system.

- 按照安装向导完成安装。

Follow the installation wizard to complete the installation.


2. **设置环境变量**:

**Set Environment Variables:**

- 在Windows系统中,右键点击“此电脑” -> “属性” -> “高级系统设置” -> “环境变量”。

In Windows, right-click on "This PC" -> "Properties" -> "Advanced System Settings" -> "Environment Variables".

- 在“系统变量”中找到`Path`,点击“编辑”,然后添加JDK的`bin`目录路径(例如:`C:\Program Files\Java\jdk-版本号\bin`)。

Find `Path` in "System Variables", click "Edit", and add the JDK's `bin` directory path (e.g., `C:\Program Files\Java\jdk-version\bin`).

- 在macOS或Linux系统中,编辑`~/.bash_profile`或`~/.bashrc`文件,添加以下行:

On macOS or Linux, edit the `~/.bash_profile` or `~/.bashrc` file and add the following lines:

```bash

export JAVA_HOME=
/Library/Java/JavaVirtualMachines/jdk-版本号.jdk/Contents/Home

export PATH=$JAVA_HOME/bin:$PATH

```

- 保存文件并执行`source ~/.bash_profile`或`source ~/.bashrc`使更改生效。

Save the file and execute `source ~/.bash_profile` or `source ~/.bashrc` to apply the changes.


3. **验证安装**:

**Verify Installation:**

- 打开终端或命令提示符,输入`java -version`和`javac -version`,如果显示版本信息,则说明安装成功。

Open the terminal or command prompt, type `java -version` and `javac -version`. If the version information is displayed, the installation is successful.


4. **安装IDE**:

**Install IDE:**

- 下载并安装你选择的IDE(如IntelliJ IDEA)。

Download and install your chosen IDE (e.g., IntelliJ IDEA).

- 启动IDE并创建一个新的Java项目。

Launch the IDE and create a new Java project.


---


#### 3. 第一个Java程序

**3. Your First Java Program**

让我们编写并运行一个简单的Java程序。

Let's write and run a simple Java program.


##### 步骤:

**Steps:**

1. 打开你的IDE,创建一个新的Java项目。

Open your IDE and create a new Java project.

2. 在项目中创建一个新的Java类文件,命名为`HelloWorld.java`。

Create a new Java class file in the project and name it `HelloWorld.java`.

3. 在`HelloWorld.java`文件中输入以下代码:

Enter the following code in the `HelloWorld.java` file:

```java

public class HelloWorld {

public static void main(String[] args) {

System.out.println("Hello, World!");

}

}

```

4. 保存文件并运行程序。你应该会在控制台看到输出:

Save the file and run the program. You should see the following output in the console:

```

Hello, World!

```


---


#### 4. 代码解释

**4. Code Explanation**

- `public class HelloWorld`:定义了一个名为`HelloWorld`的公共类。类名必须与文件名相同。

`public class HelloWorld`: Defines a public class named `HelloWorld`. The class name must match the file name.

- `public static void main(String[] args)`:这是Java程序的入口点。`main`方法是程序开始执行的地方。

`public static void main(String[] args)`: This is the entry point of a Java program. The `main` method is where the program starts execution.

- `System.out.println("Hello, World!");`:这行代码用于在控制台输出文本。

`System.out.println("Hello, World!");`: This line of code is used to print text to the console.


---


### 作业

**Homework**

1. 确保你已经成功安装JDK并设置好环境变量。

Make sure you have successfully installed the JDK and set up the environment variables.

2. 在你的IDE中创建一个新的Java项目,并编写并运行`HelloWorld`程序。

Create a new Java project in your IDE, write, and run the `HelloWorld` program.

3. 尝试修改`HelloWorld`程序,使其输出不同的文本。

Try modifying the `HelloWorld` program to output different text.


如果你有任何问题或遇到困难,请随时向我提问。下一课我们将深入学习Java的基本语法和数据类型。祝你学习愉快!

If you have any questions or encounter difficulties, feel free to ask me. In the next lesson, we will dive deeper into Java's basic syntax and data types. Happy learning!

相关推荐

让Mac也能读取Android设备文件(mac系统能读取win的文件么)

由于苹果的iOS和谷歌的Android系统属于竞争关系,因此苹果的电脑系统MacOSX并不支持MTP协议,这就使得通过USB将Android设备连接到Mac电脑上无法识别,更别说读取里面的文件了。...

抛弃Windows吧!谷歌推免费Chrome系统,一个U盘就搞定

在目前的个人电脑上,最主流的系统当然是Windows,不过除了Windows之外,我们也可以选择购买苹果的电脑,使用苹果的MacOS系统。不过除了苹果和微软的系统之外,实际上谷歌也有自己用于个人电脑...

安卓版Apple Music应用正式上架Google Play

IT之家讯11月11日消息,苹果今天正式推出了安卓版AppleMusic应用(测试版),用户可在谷歌应用商店GooglePlay进行下载。AppleMusic最初只提供给Mac、iPhone和...

Mac 基于HTTP方式访问下载共享文件,配置共享服务器

方法一:使用Python的SimpleHTTPServer进行局域网文件共享Mac自带Python,所以不需要安装其他软件,一条命令即可1):进入需要共享的文件夹,如Public文件夹cd/Us...

谷歌 Gmail 现可设置为 iOS 14/iPadOS 14 默认邮件应用

IT之家9月22日消息据外媒MacRumors报道,苹果iOS14与iPadOS14允许用户将第三方应用设置为iPhone和iPad的默认浏览器应用。目前,用户还可以将第三方...

终于免费了!谷歌地球专业版下载(谷歌地球专业版多少钱)

IT之家(www.ithome.com):终于免费了!谷歌地球专业版下载IT之家讯1月31日消息,谷歌地球专业版GoogleEarthPro现在完全免费了。在此之前,要使用这款专业版的谷歌地球需要...

谷歌计划将于11月发布64位Mac版Chrome

投稿by:hnn072来源:威锋网PostTime:2014-09-1523:51:55以下为文章全文:威锋网9月15日消息,日前,谷歌公司在官方博客中正式宣布,谷歌将在今年11月发布的...

Google首次推出beta版的64位Mac Chrome浏览器

在宣布Windows版的64位Chrome进入稳定版(Chrome37)2天之后,Google刚刚又发布38版的Chromebeta版,除了增加新的用户档案切换界面并引入G...

YouTube应用下载全攻略:安卓、iOS及视频下载指南

#哪些网站帮你打开了新世界的大门?#YouTube是全球最大的视频分享平台,拥有数十亿用户。它允许用户上传、分享和观看视频,涵盖娱乐、教育、新闻、音乐、博客、游戏等各类视频。通常,您可以使用You...

MaterialDesign来袭!iOS谷歌浏览器更新!

今日,谷歌发布了最新的iOS版Chrome浏览器应用升级,在新版本中该应用添加了最新的MaterialDesign界面,并增加了在iOS设备和Mac中快速无缝切换浏览内容的Handoff特性支持。最...

谷歌为Canary/Dev分支Mac版Chrome浏览器64位支持

【巴士速递·移动情报站】上周,谷歌为Windows7和8系统用户推出了64位版本的Chrome浏览器Beta测试版。现在,谷歌悄悄的为Canary和Dev分支Mac版Chrome浏览器增加了64位支...

谷歌发布64位Chrome for Mac 首个测试版

投稿by:水木之向来源:威锋网PostTime:2014-08-2921:52:52以下为文章全文:威锋网8月29日消息,在发布64位ChromeforWindows之后,谷歌日...

Google Stadia首发支持设备中确认有Pixel 4和Pixel 2系列

2019-10-3110:20谷歌今天宣布扩充GoogleStadia的首发支持设备规模,继Pixel3系列、Pixel3a系列之外还添加了Pixel4系列和Pixel2系列四款机型。据...

64位谷歌浏览器Chrome 11月登陆苹果OS X

IT之家(www.ithome.com):64位谷歌浏览器Chrome11月登陆苹果OSX谷歌将于11月正式发布非beta版的、苹果OSX系统的64位谷歌浏览器,谷歌于一个月前曾推出beta版的...

外媒:谷歌推出了搭载苹果M1芯片Mac的Chrome版本

据外媒TheVerge消息,谷歌日前为苹果的ArmMacs发布了Chrome的本地版本。不过该版本原本是在周二开始推出,但由于意外崩溃而暂停了。Chrome产品经理MarkChang表示,谷歌计...