CentOS7 Installing the Java SDK (OPENJDK) using the Yum command

Source: Internet
Author: User

CentOS 6.X and 7.X comes with OPENJDK runtime Environment (OPENJDK). It is a Java platform that implements open source on Linux.

Installation method:

1. Enter the following command to see a list of available JDK packages;

Yum Search Java | Grep-i--color JDK

2. Installing the JAVA SDK on CentOS Linux
At the command-line terminal, enter the following command with the root user yum installs Opensdk:

Yum Install java-1.8.0-openjdk java-1.8.0-openjdk-devel #安装openjdk

The completion of the above command indicates that the JDK installation was successful.

3. Set java_home environment variable (java_home environment variable) on CentOS Linux

After using the Yum command with Rhel and CentOS Linux, install OPENSDK to the/usr/lib/jvm/directory:

4, with the CD command into the only directory under the JVM java-1.8.0-openjdk-1.8.0.51.x86_64, and jre-1.8.0-openjdk.x86_64 this link is pointing to Java-1.8.0-openjdk-1.8.0.51.x86_64 This folder, so you can directly use the Export command to point java_home to jre-1.8.0-openjdk.x86_64 this link.
Even with the Export command:

Export java_home=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.51.x86_64

However, this is only valid in the current session, and once you log off the downline, it becomes invalid.

5, the standard way to configure environment variables

Do the following:

Vi/etc/profile

Paste the following three lines into/etc/profile:
Export java_home=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.51.x86_64
Export classpath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
Export path= $PATH: $JAVA _home/bin

Save off, After, execute: Source/etc/profile #让设置立即生效.

Enter the following command to confirm that the three variables are set to what we want:

[Email protected]~]# echo $JAVA _home
[Email protected] ~]# echo $CLASSPATH
[Email protected] ~]# echo $PATH

6. Test whether Java installation configuration is successful

To view the Java version, enter the command:
[[Email protected]~]# java-version

7, create a Java applet test, named Helloworld.java, enter the following command:
[email protected] ~]# Touch Helloworld.java

Copy the following code into Helloworld.java:
public class HelloWorld {
Pu
Blic static void Main (string[] args) {
System.out.println ("Hello, world! This was a test code by nixcraft! ");
}
}

After copying it, save the closed file. Compile and run the applet and enter the following command:
[Email protected] ~]# Javac Helloworld.java
[Email protected] ~]# java HelloWorld

Will get the following display:
Hello, world!. This was a test code by nixcraft!

8. How (how) to run. Jar Java applications like this?

The syntax is as follows:
[Email protected]~]# Java-jar File.jar
[[Email protected]~]# java-jar/path/to/my/java/app.jar #/path/to/my/java/app.jar Indicates the path of the app
[[email protected] ~]# java-jar/path/to/my/java/app.jar arg1 arg2 # arg1 = parameter 1, arg2 = parameter 2

CentOS7 Installing the Java SDK (OPENJDK) using the Yum command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.