How to get java path in CentOS?

前端 未结 4 559
旧巷少年郎
旧巷少年郎 2020-12-05 20:36

I need to configure my Jenkins Server and I need to add Java path to Jenkins configuration.

yum install java-1.8.0-openjdk

Ho

相关标签:
4条回答
  • 2020-12-05 20:55

    Try echo $JAVA_HOME or look in vi ~/.bash_profile

    0 讨论(0)
  • 2020-12-05 20:57

    They usually reside in /usr/lib/jvm. You can list them via ll /usr/lib/jvm. The value you need to enter in the field JAVA_HOME in jenkins is /usr/lib/jvm/java-1.8.0-openjdk.

    Update

    when I look at '/usr/lib/jvm' I get ...

    What you see there is a list of symbolic links pointing to a similar target located in /etc/alternatives. In the end they all point to the same target. The difference is only the name which allows you to choose how explicit your choice if the target version shall be.

    (Because java-1.8.0-openjdk is missing: Maybe you also need to install the package java-1.8.0-openjdk-devel.)

    0 讨论(0)
  • 2020-12-05 21:00

    Here are the solution

    # cd /opt/jdk1.7.0_79/
    # alternatives --install /usr/bin/java java /opt/jdk1.7.0_79/bin/java 2
    # alternatives --config java
    # alternatives --install /usr/bin/jar jar /opt/jdk1.7.0_79/bin/jar 2
    # alternatives --install /usr/bin/javac javac /opt/jdk1.7.0_79/bin/javac 2
    # alternatives --set jar /opt/jdk1.7.0_79/bin/jar
    # alternatives --set javac /opt/jdk1.7.0_79/bin/javac 
    # java -version
    
    java version "1.7.0_79"
    Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
    Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
    
    # export JAVA_HOME=/opt/jdk1.7.0_79
    # export PATH=$PATH:/opt/jdk1.7.0_79/bin
    

    Thanks to tecadmin

    0 讨论(0)
  • 2020-12-05 21:12

    try this if java command works

    readlink -f $(which java)
    
    0 讨论(0)
提交回复
热议问题