The Java version is incorrect after installing Java on CentOS

Source: Internet
Author: User

Install the JDK with CentOS today and find that when the installation is complete, enter the Java command to verify if the installation is successful.

Usage:gij [OPTION] ... CLASS [ARGS] ...
To invoke Class.main, or
Gij-jar [OPTION] ... Jarfile [ARGS] ...
To execute a JAR file
Try ' gij--help ' for more information.

Feel very strange, how to appear gij, in the online search error occurred because the Linux system is not the default point to the JDK version of the installation, so, to view the next

[email protected] ~]# which Java
/usr/bin/java
[Email protected] ~]# ls/usr/bin/java-l
lrwxrwxrwx. 1 root root 22 September 11:37/usr/bin/java-/etc/alternatives/java
[Email protected] ~]# Ll/etc/alternatives/java
lrwxrwxrwx. 1 root root 35 September 11:37/etc/alternatives/java-/usr/lib/jvm/jre-1.5.0-gcj/bin/java
[Email protected] ~]# java-version
Java Version "1.5.0"
Gij (GNU libgcj) version 4.4.7 20120313 (Red Hat 4.4.7-3)
Copyright (C) Free Software Foundation, Inc.
This was free software;  See the source for copying conditions. There is NO
Warranty Not even to merchantability or FITNESS for A particular PURPOSE.


OK, we see that the red font does point to the JDK I just installed myself, and the index needs to be introduced using the alternatives tool to modify:

[Email protected] ~]# Alternatives--install/usr/bin/java Java/usr/java/jdk1.7.0_25/bin/java 300

Once again, enter the Java-version command to verify that the discovery remains unchanged, OK, and a step important operation:

[Email protected] ~]# Alternatives--config java

A total of 2 programs provide "Java".

Select command
-----------------------------------------------
*+ 1/usr/lib/jvm/jre-1.5.0-gcj/bin/java
2/usr/java/jdk1.7.0_25/bin/java

Press Enter to save the current selection [+], or type the selection number: 2

OK, all the changes have been completed, let's enter the Java command, see the results we want, problem solving.

Reboot the system and reconfigure if not yet. Directory is/etc/profile

This article is from "Ghost" blog, please make sure to keep this source http://fangwei009.blog.51cto.com/5234706/1673279

The Java version is incorrect after installing Java on CentOS

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.