Maven compile "Cannot find symbol"

quarks picture quarks · Apr 30, 2015 · Viewed 55.3k times · Source

For some reason this command works fine with my local machine:

mvn clean install -DskipTests=true -Psdk

However for Codeship it does now work and throws this "Cannot find symbol" error. In Codeship the full command is:

jdk_switcher use oraclejdk8
echo $JAVA_HOME
mvn clean install -DskipTests=true -Psdk

In the POM the repository have this:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
        <source>1.7</source>
        <target>1.7</target>
    </configuration>
</plugin>

Error:

[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ client-app ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 65 source files to /home/rof/src/bitbucket.org/company/client-app/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/rof/src/bitbucket.org/company/client-app/src/main/java/com/client/rest/resources/MyResource.java:[3,61] cannot find symbol
symbol:   class MyEntity

Answer

Shubham Jain picture Shubham Jain · Jul 29, 2015

Your Maven is reading Java version as 1.8, Where as the pom.xml says the version is 1.7.

Try installing the required verison.

If already installed check your $JAVA_HOME environment variable, it should contain the path of Java JDK 8. If you dont find it, fix your environment variable.

also remove the lines

 <fork>true</fork>
     <executable>${JAVA_1_8_HOME}/bin/javac</executable>

from the pom.xml