Travis build OpenJDK10 with JavaFx support

Viewed 567

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.
3 Answers

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>

Teavis build with OpenJDK 8

language: java
dist: bionic
jdk:
  - openjdk8
before_install:
  - sudo apt-get update -q
  - sudo apt install openjfx=8u161-b12-1ubuntu2 libopenjfx-java=8u161-b12-1ubuntu2 libopenjfx-jni=8u161-b12-1ubuntu2
  - chmod +x deploy.sh
after_success:
  - ./deploy.sh

You need a proper setup of OpenJFX to bring it to work since JavaFX is not included in OpenJDK and also you should upgrade to OpenJDK 11 since Java 10 is EOL (End of Life).

Checkout the official documentation: https://openjfx.io/

OpenJDK 11: https://jdk.java.net/11/

Related