Project Development Environment Construction notes (2. JDK installation-replaces the original OPENJDK)

Source: Internet
Author: User
Tags centos
Author: fbysss
QQ: Wine bar Bar I scattered
Blog:blog.csdn.net/fbysss
Disclaimer: This article by fbysss original, reproduced please indicate the source

Preface: Under CentOS, Java is already installed, version 1.7, but there are no environment variables such as Java_home. So:

Export java_home=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9

Export classpath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar

Export path= $PATH: $JAVA _home/bin

However, OPENJDK and Oracle's JDK are still different. Installing the official version feels better.

Then, download Jdk7 for installation.

problem 1:centos, rz,sz such a transfer file command does not

Resolution 1:

wget http://freeware.sgi.com/source/rzsz/rzsz-3.48.tar.gz

or wget ftp://rpmfind.net/linux/centos/6.5/os/x86_64/Packages/lrzsz-0.12.20-27.1.el6.x86_64.rpm.

Here's the problem:

RPM-RVH./lrzsz-0.12.20-27.1.el6.x86_64.rpm

Error occurred:

Rpm:arguments to--root (-R) must begin with A/

Resolution 2:

It turned out that the order was wrong. Should be

rpm-ivh./lrzsz-0.12.20-27.1.el6.x86_64.rpm

RPM-IVH jdk-7u71-linux-x64.rpm

Preparing ... ########################################### [100%]

PACKAGEJDK-2000:1.7.0_71-FCS.X86_64 is already installed

So, where does Java actually install it?

RPM-QL jdk-7u71-linux-x64

Output:

Package jdk-7u71-linux-x64 are not installed

Why . What the hell?

Rpm-qa |grep Java to view installed packages

Tips: If you want to see more details, you can use Rpm-qai

[root@localhost sss]# rpm-qa |grep jdk

Java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64

Java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64

Jdk-1.7.0_71-fcs.x86_64

The original CentOS has already installed this thing. In RPM's own JDK, it is not a hint of success, but a hint that there is already a JDK, there is no successful installation.

Rpm-e jdk-1.7.0_71-fcs.x86_64

Rpm-e java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64

In this way, at least Java version 1.7 will no longer be available.

jdk-1.7.0_71-fcs.x86_64 re-installed (note that the RPM package name is not the same)

So, it may have been installed. Maybe just don't need to uninstall also can, but there are two 1.7 just, through Java_home,path and Classpath and other settings can be.

Ls-l--full-time/usr/java/jdk1.7.0_71 can see that the full installation time, the indication is really just installed.

[Root@localhost sss]#/usr/java/jdk1.7.0_71/bin/java-version

Java Version "1.7.0_71"

Java (TM) SE Runtime Environment (build 1.7.0_71-b14)

Java HotSpot (TM) 64-bit Server VM (build 24.71-b01, Mixedmode)

As you can see, this Java is no longer an open JDK.

Ok.

Vi/etc/profile

Add at the end of the file

Export java_home=/usr/java/jdk1.7.0_71

Exportclasspath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar

Export path= $PATH: $JAVA _home/bin

Source/etc/profile

But here's the problem.

java-verion

that's what happens.

OpenJDK Runtime Environment (IcedTea6 1.13.0pre) (rhel-1.66.1.13.0.el6-x86_64)

OpenJDK 64-bit Server VM (build 23.25-b01, Mixed mode)

It's easy to find out that/usr/bin has a Java

[Sss@localhost ~]$ Ll/usr/bin/java

lrwxrwxrwx. 1 root root 5 20:30/usr/bin/java-/etc/alternatives/java

Found this to be a link

[Sss@localhost ~]$ ll/etc/alternatives |grep java

You can see the further links

lrwxrwxrwx. 1 root root 5 20:30 Java->/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java

Delete this link:

Alternatives--remove Java/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java

[Sss@localhost ~]$ ll/etc/alternatives |grep java

Java-/usr/lib/jvm/jre-1.5.0-gcj/bin/java

I'll go... The next version is automatically linked.

It seems that this alternatives is a story.

Http://www.cnblogs.com/killkill/archive/2010/08/23/1806468.html

Read this article and know how to do it.

As you can imagine, using

Alternatives --config java

You can see that multiple versions of Java are managed.

It is not too late, there is a 1.5 version, we do not uninstall. Add a direct version of Sun 1.7:

If there is a mistake in the middle, remove. To change the priority, just overwrite the install and hit it again.

For example Alternatives--remove java/usr/java/jdk1.7.0_71/java--This path does not exist, there is a problem, remove.

[root@localhost sss]# alternatives--display java

Java-status is manual.

Link currently points To/usr/java/jdk1.7.0_71/bin/java

/usr/lib/jvm/jre-1.5.0-gcj/bin/java-priority 1500

Slave Keytool:/usr/lib/jvm/jre-1.5.0-gcj/bin/keytool

Slave rmiregistry:/usr/lib/jvm/jre-1.5.0-gcj/bin/rmiregistry

Slave jre_exports:/USR/LIB/JVM-EXPORTS/JRE-1.5.0-GCJ

Slave JRE:/USR/LIB/JVM/JRE-1.5.0-GCJ

/usr/java/jdk1.7.0_71/bin/java-priority 1000

Slave keytool: (null)

Slave rmiregistry: (null)

Slave jre_exports: (null)

Slave JRE: (null)

Current ' best ' version Is/usr/lib/jvm/jre-1.5.0-gcj/bin/java.

Why or 1.5 is best.

It turns out to be a priority issue.

Alternatives--install/usr/bin/java Java/usr/java/jdk1.7.0_71/bin/java 1600

So it's over.

Current ' best ' version Is/usr/java/jdk1.7.0_71/bin/java.

Here are two very useful commands:

which and Whereis

Because we are in the command, such as Javac, sometimes do not know which version, Javac No version number of this parameter, at least through the which javac to see which path it.

Whereis is to list the directories in which the commands are located.

Both commands look for an environment variable $path (not a full-range scan), but which only finds the first, Whereis all.

/usr/bin/javac can not know the version, how the whole.

Ll/usr/bin/javac

[root@localhost sss]# Ll/usr/bin/javac

lrwxrwxrwx. 1 root root 5 20:32/usr/bin/javac-/usr/java/default/bin/javac

ll/usr/java/default/bin/, the original directory also has Java

Java-version,ok, is the right JDK

Java and Javac in the same directory, Java is no problem, Javac is no problem.

ll--full-time/usr/java/default/can also see that the bin directory was just created.



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.