Share yum install java 8

thaihongenter1

New member
** #yum #Install #Java #8 **

** Cách cài đặt Java 8 trên Centos 7 bằng Yum **

Java là một ngôn ngữ lập trình phổ biến được sử dụng để phát triển nhiều ứng dụng.Phiên bản mới nhất của Java là Java 8, được phát hành vào tháng 3 năm 2014. Hướng dẫn này sẽ chỉ cho bạn cách cài đặt Java 8 trên máy chủ Centos 7 bằng Trình quản lý gói Yum.

** Điều kiện tiên quyết **

Để làm theo hướng dẫn này, bạn sẽ cần những điều sau đây:

* Máy chủ Centos 7 có tối thiểu 2GB RAM
* Người dùng không root có đặc quyền sudo

** Cài đặt Java 8 **

Để cài đặt Java 8, bạn có thể sử dụng lệnh YUM sau:

`` `
sudo yum cài đặt java-1.8.0-openjdk
`` `

Điều này sẽ cài đặt gói Java 8 OpenJDK trên máy chủ của bạn.

** Xác minh cài đặt **

Sau khi cài đặt hoàn tất, bạn có thể xác minh rằng Java 8 được cài đặt bằng cách chạy lệnh sau:

`` `
java -version
`` `

Bạn sẽ thấy đầu ra tương tự như sau:

`` `
Phiên bản Java "1.8.0_201"
Java (TM) SE môi trường thời gian chạy (Build 1.8.0_201-B09)
VM máy chủ nóng Java (TM) VM máy chủ 64 bit (Build 25.201-B09, Chế độ hỗn hợp)
`` `

** Đặt biến môi trường Java 8 **

Để biến Java 8 thành phiên bản Java mặc định trên máy chủ của bạn, bạn có thể đặt biến môi trường `java_home`.

Để thực hiện việc này, hãy mở tệp `/etc/coliting` trong trình soạn thảo văn bản và thêm dòng sau:

`` `
Xuất Java_home =/usr/lib/jvm/java-1.8.0-openjdk
`` `

Lưu và đóng tập tin.Sau đó, tải lại cấu hình bằng cách chạy lệnh sau:

`` `
Nguồn /etc /hồ sơ
`` `

** Thử nghiệm Java 8 **

Để kiểm tra Java 8, bạn có thể tạo một chương trình Java đơn giản và biên dịch nó.

Tạo một tệp mới có tên là `helloworld.java` và thêm mã sau:

`` `
lớp công khai Helloworld {
công khai void void main (String [] args) {
System.out.println ("Xin chào, thế giới!");
}
}
`` `

Lưu tệp và biên dịch nó bằng lệnh sau:

`` `
Javac Helloworld.java
`` `

Điều này sẽ tạo ra một tệp `helloworld. class`.

Để chạy chương trình, hãy sử dụng lệnh sau:

`` `
Java Helloworld
`` `

Bạn sẽ thấy đầu ra sau:

`` `
Chào thế giới!
`` `

**Phần kết luận**

Trong hướng dẫn này, bạn đã học cách cài đặt Java 8 trên máy chủ Centos 7 bằng Trình quản lý gói Yum.Bạn cũng đã học cách xác minh cài đặt và đặt biến môi trường Java 8.Cuối cùng, bạn đã thử nghiệm Java 8 bằng cách tạo và chạy một chương trình Java đơn giản.

** hashtags **

* #Java
* #java8
* #Centos
* #yum
* #cài đặt
=======================================
**#Yum #Install #Java #8**

**How to Install Java 8 on CentOS 7 using Yum**

Java is a popular programming language that is used to develop a wide variety of applications. The latest version of Java is Java 8, which was released in March 2014. This tutorial will show you how to install Java 8 on a CentOS 7 server using the Yum package manager.

**Prerequisites**

To follow this tutorial, you will need the following:

* A CentOS 7 server with a minimum of 2GB of RAM
* A non-root user with sudo privileges

**Installing Java 8**

To install Java 8, you can use the following Yum command:

```
sudo yum install java-1.8.0-openjdk
```

This will install the Java 8 OpenJDK package on your server.

**Verifying the Installation**

Once the installation is complete, you can verify that Java 8 is installed by running the following command:

```
java -version
```

You should see output similar to the following:

```
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
```

**Setting the Java 8 Environment Variable**

To make Java 8 the default Java version on your server, you can set the `JAVA_HOME` environment variable.

To do this, open the `/etc/profile` file in a text editor and add the following line:

```
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
```

Save and close the file. Then, reload the profile by running the following command:

```
source /etc/profile
```

**Testing Java 8**

To test Java 8, you can create a simple Java program and compile it.

Create a new file called `HelloWorld.java` and add the following code:

```
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
```

Save the file and compile it using the following command:

```
javac HelloWorld.java
```

This will create a `HelloWorld.class` file.

To run the program, use the following command:

```
java HelloWorld
```

You should see the following output:

```
Hello, world!
```

**Conclusion**

In this tutorial, you learned how to install Java 8 on a CentOS 7 server using the Yum package manager. You also learned how to verify the installation and set the Java 8 environment variable. Finally, you tested Java 8 by creating and running a simple Java program.

**Hashtags**

* #Java
* #java8
* #Centos
* #yum
* #Install
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top