Kiran
Kiran

Reputation: 1197

How to set the correct path for JRE and JDK while building through jenkins in CentOS 7?

I am facing an issue with the jenkins build in one of our servers.

Issue is :

[ERROR] PATH_TO_FILE/EventsServiceImpl.java:[1592,137] method references are not supported in -source 1.5

enter image description here

EventsServiceImpl.java:[1592,137] contains the following code.

List<String> androidDevicesList = deviceIds.getDeviceIds().stream().map(Object::toString)
                                    .collect(Collectors.toList());

By the looks of the issue, it is saying that the jenkins build is taking 1.5 to build the code. where the above code needs java 8 to compile. I have done everything to set the path correctly. I have checked the $JAVA_HOME path in the server. And it points to the correct JRE version. i.e. 1.8.0_111

I also checked my Jenkins JDK path and it is correct as far as I knew.

enter image description here

It is working fine in my local system. My Eclipse compiles it without any issue. But if I change the java compiler from 1.8 to 1.7 / 1.5, it is throwing the error.

My System Config:

OS: Windows 7

JDK: 8

JRE: 1.8.0_31

Server Configurations:

OS: Cent OS 7

JDK: 8

JRE: 1.8.0_111

I don't know, exactly what is the issue? Is it the issue with Jenkins? or is it the issue with Java compiler path in the server? Or is it the issue with Mavan in the server.

And also I have ran sample java file in the server with the above code in it. I ran without any issue. I am able to compile the code and build the code and saw the output.

Upvotes: 0

Views: 1229

Answers (1)

garyl
garyl

Reputation: 41

The "-source 1.5" indicates that the java compiler, even though JDK 8, is being told to compile the code at JDK 5 level. It's not possible to tell definitively where this is coming from given the information posted. Please post your pom.xml file or check it (see this for more info) for a

<source>

tag. Also check the Build section of your Jenkins project configuration to make sure it isn't being set as a command line option there.

Upvotes: 1

Related Questions