Issue
I have configured Jenkins on AWS RHEL-8.6 EC2 instance. Also setup the java path variable in bash profile. I am getting below error while configuring JDK path in Jenkins.
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.342.b07-2.el8_6.x86_64 doesn’t look like a JDK directory
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.342.b07-2.el8_6.x86_64
PATH=$PATH:$JAVA_HOME:$HOME/bin
[root@ip-172-31-0-152 ~]# find /usr/lib/jvm/java-1.8* |head -n 20
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.342.b07-2.el8_6.x86_64
Solution
I think there is maybe a mistake in your initial PATH. Login to your account and open .bash_profile file in your home. You can use vi or nano to edit it...
nano ~/.bash_profile
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.342.b07-2.el8_6.x86_64
export PATH=$JAVA_HOME/bin:$PATH
Don't forget to update your current user sesssion from a terminal to activate the new path settings : source ~/.bash_profile
Answered By - Quentin Genet
Answer Checked By - Gilberto Lyons (JavaFixing Admin)