Set OpenJDK environment variables in CentOS

Source: Internet
Author: User

Set OpenJDK environment variables in CentOS
When I installed phpstorm today, I was prompted that I could not find JAVA_HOME, So I remembered that I had not installed JDK! Try openJDK on linux!

Centos comes with OpenJDK's Runtime (JRE). In "Add/Delete", we can find JDK (OpenJDKDevelopmentEnvironment) and install it.

After the installation, there are no system variables such as java_home, and you need to add them yourself.

However, the openJDK installation directory is different from the common SunJDK storage directory.

(Many people abandon openJDK When configuring environment variables)

I want to die when I flip through the directory ...... (Because centos does not open a directory, it is a new window), online search, Chinese Web page results are really not! I finally found a solution on the openJDK official forum!

After openJDK is installed, the directory is located in/usr/lib/jvm, including jre and jdk.


You can see "bin" in the "java-1.6.0-openjdk-1.6.0.0" Directory (if not, it means that your openJDKforJDK has not been installed, please go back to the second sentence on this page, carefully study !) You can find the javac file in the bin, indicating that this is JDK!

In this case, you only need to open the environment variable file suvi/etc/profile in the terminal (Save the command and Press ESC, then enter ": w" to save the file, and then ": q" to exit vi) enter the corresponding directory:

ExportJAVA_HOME =/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.

ExportCLASSPATH =.: $ JAVA_HOME/jre/lib/rt. jar: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar

ExportPATH = $ PATH: $ JAVA_HOME/bin

In this way, we have set the JDK and it will take effect after entering source/etc/profile.

In this case, try to enter the command "javac" to check out ~?

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.