0

I am getting compilation error while building a code in jenkins. I am using java 1.8 but can not see any mistake as I have configured JAVA_HOME path and maven path shown below.I have only one subfolder ie jre inside openjdk1.8 folder. I am confused is it any configuration mistake or I have wrong jdk file installed.

JAVA_HOME I have set java_home path in /etc/bashrc as
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64/

[neha.verma@sgpjenkins lib]$ which java
/usr/bin/java

[neha.verma@sgpjenkins ~]$ javac -version
-bash: javac: command not found
[neha.verma@sgpjenkins ~]$ java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)
[neha.verma@sgpjenkins ~]$ echo $JAVA_HOME
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64/

FOLDER Details

[neha.verma@sgpjenkins ~]$ cd /usr/lib/jvm/
[neha.verma@sgpjenkins jvm]$ ls -lrt
total 0
drwxr-xr-x 3 root root 17 Apr 29 05:18 java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64
lrwxrwxrwx 1 root root 51 May  4 14:02 jre-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64 -> java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64/jre
lrwxrwxrwx 1 root root 27 May  4 14:03 jre-1.8.0 -> /etc/alternatives/jre_1.8.0
lrwxrwxrwx 1 root root 35 May  4 14:03 jre-1.8.0-openjdk -> /etc/alternatives/jre_1.8.0_openjdk
lrwxrwxrwx 1 root root 21 May  4 16:24 jre -> /etc/alternatives/jre
lrwxrwxrwx 1 root root 29 May  4 16:24 jre-openjdk -> /etc/alternatives/jre_openjdk

SUB-FOLDER details

[neha.verma@sgpjenkins java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64]$ ls -lrt
total 0
drwxr-xr-x 4 root root 28 May  4 14:02 jre
[neha.verma@sgpjenkins java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64]$ cd jre/
[neha.verma@sgpjenkins jre]$ ls
bin  lib
[neha.verma@sgpjenkins jre]$ cd bin/
[neha.verma@sgpjenkins bin]$ ls -lrt
'total 240
-rwxr-xr-x 1 root root 122184 Apr 29 05:20 unpack200
-rwxr-xr-x 1 root root   9168 Apr 29 05:20 tnameserv
-rwxr-xr-x 1 root root   9120 Apr 29 05:20 servertool
-rwxr-xr-x 1 root root   9120 Apr 29 05:20 rmiregistry
-rwxr-xr-x 1 root root   9112 Apr 29 05:20 rmid
-rwxr-xr-x 1 root root   9120 Apr 29 05:20 policytool
-rwxr-xr-x 1 root root   9112 Apr 29 05:20 pack200
-rwxr-xr-x 1 root root   9168 Apr 29 05:20 orbd
-rwxr-xr-x 1 root root   9112 Apr 29 05:20 keytool
-rwxr-xr-x 1 root root   9112 Apr 29 05:20 jjs
-rwxr-xr-x 1 root root   8984 Apr 29 05:20 java
[neha.verma@sgpjenkins bin]$ cd ..
[neha.verma@sgpjenkins jre]$ cd lib/
[neha.verma@sgpjenkins lib]$ ls -lrt
total 79768
-rw-r--r-- 1 root root     1210 Apr 29 05:05 sound.properties
-rw-r--r-- 1 root root  3509687 Apr 29 05:05 resources.jar
-rw-r--r-- 1 root root     3793 Apr 29 05:05 psfont.properties.ja
-rw-r--r-- 1 root root    11390 Apr 29 05:05 psfontj2d.properties
-rw-r--r-- 1 root root     5352 Apr 29 05:05 net.properties
-rw-r--r-- 1 root root      382 Apr 29 05:05 management-agent.jar
-rw-r--r-- 1 root root     2455 Apr 29 05:05 logging.properties
-rw-r--r-- 1 root root     4226 Apr 29 05:05 jvm.hprof.txt
-rw-r--r-- 1 root root   809517 Apr 29 05:05 jsse.jar
-rw-r--r-- 1 root root   109064 Apr 29 05:05 jce.jar
-rw-r--r-- 1 root root    14959 Apr 29 05:05 hijrah-config-umalqura.properties
-rw-r--r-- 1 root root     3901 Apr 29 05:05 flavormap.properties
-r--r--r-- 1 root root     4102 Apr 29 05:05 currency.data
-rw-r--r-- 1 root root     5916 Apr 29 05:05 content-types.properties
-rw-r--r-- 1 root root    84311 Apr 29 05:05 classlist
-rw-r--r-- 1 root root  3203270 Apr 29 05:05 charsets.jar
-rw-r--r-- 1 root root     2479 Apr 29 05:05 calendars.properties
drwxr-xr-x 2 root root        6 Apr 29 05:05 applet
-rw-r--r-- 1 root root 73844502 Apr 29 05:05 rt.jar
-rw-r--r-- 1 root root     1922 Apr 29 05:05 meta-index
-rwxr-xr-x 1 root root    13736 Apr 29 05:20 jexec
drwxr-xr-x 2 root root       89 May  4 14:02 cmm
drwxr-xr-x 2 root root      203 May  4 14:02 ext
drwxr-xr-x 3 root root       21 May  4 14:02 images
drwxr-xr-x 2 root root      119 May  4 14:02 management
lrwxrwxrwx 1 root root       30 May  4 14:02 tzdb.dat -> /usr/share/javazi-1.8/tzdb.dat
drwxr-xr-x 3 root root      115 May  4 14:02 security
drwxr-xr-x 5 root root     4096 May  4 14:02 amd64

I have added compiler plugin details in pom.xml

 <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
</configuration>
</plugin>

Please help. Also Please confirm Do I need to add any details in settings.xml ??

  • 3
    You have a JRE installation there. You need a JDK installation. Only a JDK installation will give you the Java compiler (`javac`). – Stephen C May 07 '20 at 06:47
  • 1
    The error message is remarkably clear on both the cause and the solution of the problem. Kudos to Jenkins. – Bohemian May 07 '20 at 07:13
  • I was using JAVA 11 before for jenkins installation and setup after having javax dependecy issue while nexus integration I have degraded to java 8 version . But it was pre installed on my system so I did not verify its file. but after configuring java 8 when I try to build I am getting an error for jre not jdk. So I need to remove java 8 file and again dowload from oracle for linux 64bit . it will not cause any error on my jenkins setup? – user13249852 May 07 '20 at 08:15
  • I am new in java . So if I want to install jdk 8 for linux 64bit https://www.oracle.com/java/technologies/javase-jdk8-downloads.html Linux x86 Compressed Archive 186.6 MB jdk-8u251-linux-i586.tar.gz Is this a right link to download it for free as I do not have oracle account. Just to reconfirm that I am installing a right java 8 containg jdk not jre – user13249852 May 07 '20 at 08:21
  • How do I know I have installed JRE or JDK because in the parent folder I was sure that I hava java 8 installed just for future reference – user13249852 May 07 '20 at 11:24
  • How to tell if JRE or JDK is installed: https://stackoverflow.com/a/23267681/8092868 – Joep Weijers May 08 '20 at 21:37
  • And please note: the JDK 8 from Oracle can only be used for personal or development purposes. If you need to run something commercially in production you'll be looking at an OpenJDK provider, e.g. AdoptOpenjdk which provide free JDKs: https://adoptopenjdk.net/. It is advisable to build on that same version in your build pipeline. – Joep Weijers May 08 '20 at 21:45

0 Answers0