Search code examples
javajavafxtravis-cijava-10

Travis build OpenJDK10 with JavaFx support


Since a few days travis does not support the jdk option oraclejdk10 anymore. So I tried to move to openjdk10. The problem is, that I need JavaFX support, and I get various error messages for various tries to get it working:

Try 1:

language: java

install: true

script: "cd Aggregation; mvn test -B"

sudo: false
jdk:
    - openjdk10

notifications:
  email:
    recipients:
      - junktogo@web.de
    on_success: change
on_failure: always

Travis error: Multiple packages like javafx.application do not exist

Try 2 (Install the openjfx package): I added the following section:

before_install:
    - sudo apt install -y openjfx

Travis error:

E: Unable to locate package openjfx
The command "sudo apt install -y openjfx" failed and exited with 100 during.

This problem remains even if adding sudo apt update.

Try 3:

before_install:
    - sudo apt-get build-dep libopenjfx-java
    - sudo apt-get --compile source libopenjfx-java

Travis error:

E: Unable to locate package libopenjfx-java
The command "sudo apt-get build-dep libopenjfx-java" failed and exited with 100 during.

Solution

  • As Jan S. suggested including JavaFX using a Maven dependency instead of trying to build it using Travis works just fine. Add something like the following to your Maven dependencies section:

    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>11</version>
    </dependency>