How to use JDK 1.8u45 in travis or "cannot find symbol" while building Java 1.8u45


Posted by Steven

While building one of my repositories with Shippable, I got the following error:

  1. [ERROR] COMPILATION ERROR :
  2. [INFO] -------------------------------------------------------------
  3. [ERROR] /home/shippable/workspace/src/github.com/stevenschwenke/Java8Workshop/src/test/java/de/stevenschwenke/java/java8workshop/C_09_JavaFX.java:[193,13] cannot find symbol
  4. symbol: class Alert
  5. location: class de.stevenschwenke.java.java8workshop.C_09_JavaFX
  6. [ERROR] /home/shippable/workspace/src/github.com/stevenschwenke/Java8Workshop/src/test/java/de/stevenschwenke/java/java8workshop/C_09_JavaFX.java:[193,31] cannot find symbol
  7. symbol: class Alert
  8. location: class de.stevenschwenke.java.java8workshop.C_09_JavaFX
  9. [ERROR] /home/shippable/workspace/src/github.com/stevenschwenke/Java8Workshop/src/test/java/de/stevenschwenke/java/java8workshop/C_09_JavaFX.java:[193,42] package Alert does not exist
  10. [INFO] 3 errors
  11. [INFO] -------------------------------------------------------------
  12. [INFO] ------------------------------------------------------------------------
  13. [INFO] BUILD FAILURE

Solution for travis

See Travis issue 4042. Adding the lines 10 to 13 into your .travis.yml seems to cause Travis to use a newer JDK version:

  1. addons:
  2. # language
  3. language: java
  4.  
  5. # version numbers
  6. jdk:
  7. - oraclejdk8
  8.  
  9. # Use JDK 8u45. The above line just causes the use of a minor version of Java 8.
  10. addons:
  11. apt:
  12. packages:
  13. - oracle-java8-installer

That caused my build to run just fine in travis.

Solution for shippable

Unfortunately, I don't know a solution for Shippable right now. However, you can view the progress in this bug report of mine.

Update: Using a custom image as described in the mentioned ticket, I got my build working. This is my shippable.yml:

  1. # language
  2. language: java
  3.  
  4. # version numbers
  5. jdk:
  6. - oraclejdk8
  7.  
  8. before_install:
  9. - apt-get update
  10. - apt-get install -y maven
  11.  
  12. before_script:
  13. - if [[ $SHIPPABLE_JDK_VERSION == "oraclejdk8" ]] ; then export JAVA_HOME="/usr/lib/jvm/java-8-oracle"; export PATH="$PATH:/usr/lib/jvm/java-8-oracle/bin"; export java_path="/usr/lib/jvm/java-8-oracle/jre/bin/java"; fi
  14. - update-alternatives --set java $java_path
  15. - java -version
  16.  
  17. after_success:
  18. - mvn clean cobertura:cobertura
  19. - mvn test

TL;DR

Both Travis and Shippable are able to build Java 1.8u45 code, however not out of the box.

Category: 
Share: