Compiling java code in Jenkins get error: incompatible types

801 Views Asked by At

I configed Jenkins to compile and build java project. But I got the below error

[javac] C:\Users\Administrator\.jenkins\workspace\AMRM\AMRM-rad-workspace\AMRM\src\com\bidv\amrm\struts2\jdbc\DeclareAppImpl.java:232: error: incompatible types
    [javac]                   return DB.getConnection().queryForObject(sql, new Object[]{id}, new DTOMapper());
    [javac]                                                           ^
    [javac]   required: ListAppDTO
    [javac]   found:    Object

I found a solution to fix is adding the line: @SuppressWarnings("unchecked") before relate function in java code

But, are there any other solution ? Such as config in Jenkins ? I don't want to change my code, because My project still compiled success in Eclipse (but error in Jenkins)

1

There are 1 best solutions below

0
On

I found the reason, it is because my jenkins still use a different java version.

So I pass the correct version (1.6) into build statement javac, then it is successful (java.home = C:\Program Files\Java\jdk1.6.0_23)

<javac fork="yes" executable="${java.home}\bin\javac" includeantruntime="false" encoding="utf-8" srcdir="${workspace}/${project.name}/src" destdir="${workspace}/${project.name}/WebContent/WEB-INF/classes" classpath="${was_cp}">
        </javac>

But, I got another error:

Caused by: java.io.IOException: Cannot run program "C:\java1.6\bin\javac": CreateProcess error=206, The filename or extension is too long.