JDK and Tomcat configuration in CentOS

Source: Internet
Author: User

1. Querying the system default JDK

The CentOS system installs OPENJDK by default, and the general recommendation is to install the Sun Company's JDK. We first check to see if the system has a JDK and a openjdk version, and if so, uninstall it and install the version of Sun's JDK.

Query whether the system is installed OPENJDK with the following query command:

#rpm-qa |grep Java

#rpm-qa |grep JDK

#rpm-qa |grep GCJ

To query the current Java version:

From the above,

The OpenJDK 1.7.0_65 is already installed in the system.

2. Remove the installed OpenJDK

To remove the installed OPENJDK, you can use the following command:

? rpm–e JDK Related (normal delete command, delete a specific package, if you encounter dependencies, you cannot delete)

Rpm-e–nodeps JDK related (Force Delete command, ignore dependency, delete specific package. If you use the above command to delete, prompt for other dependent files, then use this command can be strongly deleted)

Note: The JDK here refers to the file of the JDK that was found in the previous step using the query command.

To force the Delete command with RPM, the following:

#rpm-E java-1.7.0-openjdk-1.7.0.65-2.5.1.2.el6_5.i686

#rpm-E Tzdata-java-2014e-1.el6.noarch

The associated JDK file was not found when the RPM query command was last executed, indicating that the JDK was removed successfully.

Next, to ensure that the JDK has been completely removed, you also need to execute the query command #find/-name JDK Related:

As you can see, the query has no effect, indicating that the JDK has been removed cleanly.

If the query out there are also participating in the directory, you can use the # RM-RF directory, the remaining directory one by one deleted.

The removal of the JDK has been completed.

3. Download and install the JDK

jdk-8u71-linux-x64.rpm

Installing the JDK

With the JDK's installation package, you can then install it.

A. Create a new Java directory in the/usr directory and place the installation package in the/usr/java directory:

b.# RPM-IVH jdk-8u71-linux-x64.rpm

3) Configure Environment variables

After installation, you need to configure the JDK environment variables.

Modify the/etc/profile file and add the following information at the end:

Java_home=/usr/java/jdk1.6.0_45

Path= $PATH: $JAVA _home/bin

Classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar

Export Java_home PATH CLASSPATH

When you have finished adding, save the exit.

In order for the/etc/profile file to take effect immediately after modification, you can use the following command:

Command : #./etc/profile

Note:. There are spaces between the/etc/profile and the

4. Test the JDK

After installing and configuring the environment variables, the next step is to test that the JDK is installed properly.

Enter Java-version or Javac-version, if the version information is displayed, the installation is successful:

As you can see, the JDK has been installed successfully. Next, let's test a simple Hello World program.

A. Create a new Hello.java file

B. Add the following code:

Save exit.

C. Compile, run:

As can be seen from the above, the JDK compiles and runs normally.

At this point, the installation of the JDK has ended successfully.

JDK and Tomcat configuration in CentOS

Related Article

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.