20

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

yum install java-1.8.0-openjdk

However I'm new to lunix command, any suggestion please?

I dont know where yum install it!

See the validated answer!

Naou
  • 726
  • 1
  • 10
  • 23
  • 1
    What do you mean by "java path". Are you asking what the path to the `java` command is, or what `$JAVA_HOME` should be set to? Or something else? – Stephen C Oct 13 '15 at 14:42
  • Thanks for your answer, I mean both getting the path where java was installed, in order to set the $JAVA_HOME . – Naou Oct 13 '15 at 14:53
  • [vagrant@localhost /]$ echo $PATH /usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/vagrant/.local/bin:/home/vagrant/bin – Naou Oct 13 '15 at 15:05

4 Answers4

29

try this if java command works

readlink -f $(which java)
Pravin Bansal
  • 4,315
  • 1
  • 28
  • 19
22

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.)

thomas.mc.work
  • 6,404
  • 2
  • 26
  • 41
  • when I look at '/usr/lib/jvm' I get '[vagrant@localhost /]$ ll /usr/lib/jvm insgesamt 0 drwxr-xr-x 3 root root 16 13. Okt 11:30 java-1.8.0-openjdk-1.8.0.60-2.b27.el7_1.x86_64 lrwxrwxrwx 1 root root 21 13. Okt 11:30 jre -> /etc/alternatives/jre lrwxrwxrwx 1 root root 27 13. Okt 11:30 jre-1.8.0 -> /etc/alternatives/jre_1.8.0 lrwxrwxrwx 1 root root 35 13. Okt 11:30 jre-1.8.0-openjdk -> /etc/alternatives/jre_1.8.0_openjdk lrwxrwxrwx 1 root root 50 13. Okt 11:30 jre-1.8.0-openjdk-1.8.0.60-2.b27.el7_1.x86_64 -> java-1.8.0-openjdk-1.8.0.60-2.b27.el7_1.x86_64/jre – Naou Oct 13 '15 at 14:59
  • I added 'java-1.8.0-openjdk-devel' as you suggest, but I have the same result. Maybe the JDK is not installed, I see just JRE – Naou Oct 13 '15 at 15:28
  • I have `java-1.8.0-openjdk-headless`, `java-1.8.0-openjdk-devel` and `java-1.8.0-openjdk` – thomas.mc.work Oct 14 '15 at 06:54
  • look at following or similar location /usr/lib/jvm/java-1.8.0-openjdk.x86_64/ – Soman Dubey Dec 16 '15 at 17:52
  • In your root folder add this to .bash_src export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk export PATH=$JAVA_HOME/bin:$PATH – GoodJeans Mar 11 '19 at 02:47
4

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

Naou
  • 726
  • 1
  • 10
  • 23
-3

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

Henni
  • 1
  • 2