CentOS installs Sun's JDK and tests

Source: Internet
Author: User

Querying the system default JDK

The CentOS system (Centos6.3 installed on my VM) installs OPENJDK by default, and you need to configure the environment variables yourself to use the default JDK.

First, check to see if the system has JDK and OPENJDK version information installed. (Here, I also see a lot of people on the internet said, to uninstall OPENJDK after the installation of Sun's JDK version (otherwise, Sun's JDK installation error). Here, I did not uninstall, still installed very OK, here to install or with the individual bar);

(please switch to the Administrator's role input command Su-) The command to query whether the system installs OPENJDK is as follows:

#rpm-qa|grep Java

#rpm-qa|grep JDK

#rpm-qa|grep GCJ

  

Several versions, so use Java-version to view the current version;

Remove an installed OPENJDK

#rpm-E (JDK version information name)

#rpm-E-nodeps (JDK version information name)

The difference between these two lines of command is that the following command is forced to delete, ignore dependencies, and delete specific packages.

For example:

#rpm-E java-1.7.0-openjdk-1.7.065-2.5.1.2.el6.5.i686

How do I know if the JDK was successfully deleted?

Then in executing the query JDK command, look at the result of the terminal output, there is no version information name of the JDK just uninstalled

  

Install Sun's JDK

Download the JDK Link: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

1. The installed version is: JDK 1.7

The role of the administrator must be used during the installation process

  

   Su--ivh  /catalogue/jdk-7-linux-x64.rpm

After downloading the files in the Linux system, review the properties to quickly get the directory address and the completion name of the JDK:

In the execution command:

  

2. Setting Environment variables

The/etc/profile appends the following information to the Profiles file: Export Java_home=/usr/java/jdk1. 7.0_75 (It is important to note that the final directory is determined with the version number of your JDK.) Please, note)export CLASSPATH=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/  Tools.jarexport PATH= $PATH: $JAVA _home//etc/profile

But it has to be export to take effect in the system, which is a two-step definition and release.

Especially when Path,export must remember to take the original path.

Path= $PATH: $HOME/bin

Otherwise, it covers the path of the system.

So if you get the version number of your JDK,

  

  Everyone: Here you can see the version number of the JDK you installed.

Query the installation path for the JDK: Echo $JAVA _home

Hello.java Test JDK

1. Test the JDK

Input # Java-version

  

2, using the VI editor under Linux to create Hello.java

#vim Hello.java

  

Here is simply a simple command of vim:

#vim [file name] to open or create file [filename]

Commands within the VIM editor:

Input I means input

Entering ESC means exiting the current command

Input: Wq disk and exit

Input: Q exit

Input: q! Forced exit (no disk)

  

  It is important to emphasize:

#vim Hello.java

In the Vim editor, be sure to use Hello as the name of the class,

Otherwise, the subsequent compilation will error:

  

Hope that you have just started to notice;

After editing the code:

Enter ESC

Input: Wq

  

Here to view the directory of Hello.java files

#ls-L

#javac Hello.java

#java Hello

  

here, all OK;

  

CentOS installs Sun's JDK and tests

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.