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

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

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

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!

相关推荐

Origin将普通双Y轴柱状图升级为高级的3D倒影柱状图

双Y轴柱状图可以在同一张图表中展示两组具有不同量纲或数量级的数据。3D倒影柱状图是一种通过三维立体及倒影形式展示多个数据的图表,它通过柱子的高度和颜色来表示不同的数据类别和数值大小,以及通过不同平面展...

Origin 2021 安装教程(附安装包下载)

Origin2021软件介绍广泛用于科研、工程和数据分析领域。它支持多种数据格式,包括Excel、ASCII、CSV等,可以方便地导入和分析各种类型的数据。Origin提供了丰富的数据分析工具,包括...

VIVO origin os系统关闭广告教程(IQOO同理)

以下是我使用期间发现的,如有其他未发现的,欢迎大家评论补充。1设置-安全-更多安全设置-广告与隐私-个性化广告推荐关闭2设置-安全-更多安全设置-应用安装-应用推荐关闭3设置-系统管理-全局搜索-首页...

Origin 2019 安装教程(附安装包下载)

Origin2019软件介绍广泛用于科研、工程和数据分析领域。它支持多种数据格式,包括Excel、ASCII、CSV等,可以方便地导入和分析各种类型的数据。Origin提供了丰富的数据分析工具,包括...

vivo开启Origin OS3系统公测,并且公布首批至第四批可升级名单

vivo在本月初发布了OriginOS3.0操作系统,11月25日开启了首批机型的公测招募活动,首批公测机型包括vivo和iQOO,共计14款机型。首批公测招募的机型有:vivoxfold+、v...

Origin将普通热图升级为高级的3D堆叠热图

3D堆叠热图是一种将多个热图组合在一起展示的图表可视化形式。每个热图代表一个数据集,通过比较不同数据集在不同条件(分组)下的颜色深浅变化来挖掘数据的大小差异或者相关性,能够直观地比较多组数据的相对强度...

最新最详细的Origin2021安装教程(保姆级)

直入正题,下面是Origin2021的安装过程安装包(复制到浏览器打开):%74%2E%63%6E/%41%36%4E%67%6D%54%74%4A安装步骤1、下载得到安装包后,请先解压!一定要先解压...

vivo和iQOO抓紧更新 OriginOS5末班车 12月最后一波升级

进入12月底了,很多老旧机型也已经开始更新各家的新系统了,所以大家一定要注意查看系统版本更新。那么就拿今年国内销量第一的vivo和iQOO来说,OriginOS5都已经推出两个月了,根据之前公布的适...

Origin将普通点线图转换为高级的3D堆叠点线图

点线图用于显示数据随时间或其他连续变量的变化趋势;点线图主要功能是展示数据随时间或连续变量的变化趋势,强调变化幅度,比较多个变量,描述周期性变化,识别异常值,并帮助分析趋势和预测未来趋势。当具有多组数...

蓝厂Origin OS 2.0首批适配机型曝光!有没有你的手机型号?

2020年11月18日蓝厂新系统OriginOS正式发布,并由后来的X60系列首发,新系统发布后网上就有言论:蓝厂补足了最后一块短板!发布至今大概已经有11月的时间了,网上也是褒贬不一,Origin...

Origin2018软件安装包以及安装教程

安装步骤:1.鼠标右击软件压缩包,选择“解压到Origin2018”2.打开“Origin2018\Origin2018”文件夹,鼠标右击“setup”,选择“以管理员身份运行”3.软件正在准备...

Origin这样操作,轻松绘制漂亮的雷达图

背景介绍雷达图是以从同一点开始的轴上表示的三个或更多个定量变量的二维图表的形式显示多变量数据的图形方法。轴的相对位置和角度通常没有信息。雷达图也称为网络图、蜘蛛图、星图、星图、蜘蛛网、不规则多边形...

曝OriginOS新版本在“玩命打磨底层”流畅性比肩鸿蒙

  日前,vivo正式官宣了2022年vivo开发者大会的举办时间:11月8日-11月9日。OriginOS全新版本届时将正式登场。时隔一年,这次全新OriginOS又将给我们带来什么样的全新体验? ...

Dify工具使用全场景:1.0.1发布了,升级(功能篇·第8期)

上一篇:Dify工具使用全场景:API扩展(功能篇·第7期)一、Dify1.0.1版本升级特性Dify1.0.1版本在稳定性、性能和用户体验方面进行了全面升级,修复了之前版本中的一些已知问题,带来...

vivo 新系统originOS 升级公测后增加手机内存

vivo新系统originOS,通过内存融合、进程优化、应用预载三种技术,一方面调用部分闲置的闪存空间,另一方面低系统对内存的占用,从而可以让原硬件内存增加2-3GB内存使用。vivo新系统ori...