skip to Main Content

I am trying to install java 11 on an amazon ec2 instance Linux , I followed the below steps:

====OS details=====

[root@ip-172-31-44-83 java-11-openjdk-11.0.16.0.8-1.amzn2.0.1.x86_64]# cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
===Install Java=====
sudo amazon-linux-extras
sudo amazon-linux-extras install java-openjdk11 -y
java --version
sudo su -
echo "export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.16.0.8-1.amzn2.0.1.x86_64" >> .bash_profile
echo "export PATH=$PATH:/usr/lib/jvm/java-11-openjdk-11.0.16.0.8-1.amzn2.0.1.x86_64/bin" >> .bash_profile 
source ~/.bash_profile
echo $JAVA_HOME
java --version

installation result: java is successfully installed and even path is also set

[root@ip-172-31-44-83 java-11-openjdk-11.0.16.0.8-1.amzn2.0.1.x86_64]# cat ~/.bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User-specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.16.0.8-1.amzn2.0.1.x86_64
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/lib/jvm/java-11-openjdk-11.0.16.0.8-1.amzn2.0.1.x86_64/bin
[root@ip-172-31-44-83 java-11-openjdk-11.0.16.0.8-1.amzn2.0.1.x86_64]#
[root@ip-172-31-44-83 java-11-openjdk-11.0.16.0.8-1.amzn2.0.1.x86_64]#
[root@ip-172-31-44-83 java-11-openjdk-11.0.16.0.8-1.amzn2.0.1.x86_64]# echo $JAVA_HOME
/usr/lib/jvm/java-11-openjdk-11.0.16.0.8-1.amzn2.0.1.x86_64
[root@ip-172-31-44-83 java-11-openjdk-11.0.16.0.8-1.amzn2.0.1.x86_64]# rpm -qa | grep jdk
java-11-openjdk-11.0.16.0.8-1.amzn2.0.1.x86_64
copy-jdk-configs-3.3-10.amzn2.noarch
java-11-openjdk-headless-11.0.16.0.8-1.amzn2.0.1.x86_64
[root@ip-172-31-44-83 java-11-openjdk-11.0.16.0.8-1.amzn2.0.1.x86_64]#

When I am adding a java path in Jenkins global tool Configuration getting the below error
"/usr/lib/jvm/java-11-openjdk-11.0.16.0.8-1.amzn2.0.1.x86_64 doesn’t look like a JDK directory
"

enter image description here

2

Answers


  1. Look like the location you are specifying doesn’t have javac.
    to make sure try to check if javac exist or not by running:
    ls /usr/lib/jvm/java-11-openjdk-11.0.16.0.8-1.amzn2.0.1.x86_64/bin/javac

    if it does not exist then try to download fresh JDK and set JAVA_HOME point to there.

    Login or Signup to reply.
  2. Error Message:

    • /usr/lib/jvm/java-11-openjdk-11.0.18.0.10-1.amzn2.0.1.x86_64 doesn’t look like a JDK directory

    Likely Cause:

    • you probably didn’t install the java devel package that will generate the javac version needed for jenkins to accept the provided path as a recognisable one.

    Solution:

    • run: yum reinstall java-11-openjdk-devel
    • to confirm installation, run: rpm -q1 java-11-openjdk-devel | grep bin/javac
    • restart jenkins by running: systemctl restart jenkins
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search