0

I have a image based on Linux (CentOS Linux) with Java OpenJDK 11. I'm trying to install javafx on the image by this dockerfile:

USER root
yum -y update   && \
yum install –y openjfx

But when i try to build the image I get "No package javafx available." and " yum install OCoy javafx' returned a non-zero code: 1" What am I doing wrong? Is there another way of including JavaFX libraries on a docker image?

4
  • Do you want to create a custom openjdk-based jdk or jre that includes JavaFX modules? (Answer would be jdk or jre or something else with a better explanation). Commented Dec 1, 2021 at 17:31
  • I want to include the JavaFX modules. I found this openjfx.io/openjfx-docs/#maven . And I'm trying now to specify the modules in the pom file and copying them to the image. Not sure if it will work Commented Dec 2, 2021 at 10:29
  • It’s not clear to me what you are trying to do, but if all you need is a custom Java runtime for your chosen platform that includes JavaFX modules, it is very to create one using jlink, which is part of any modern jdk distribution. Commented Dec 3, 2021 at 4:56
  • Or you could use jpackage to create an rpm, which your docker could install (from a yum repo if you wanted to put it there). But then, as I said, I don’t know what you want so maybe my comments don’t apply to you or are just confusing. Please ignore them if they are not relevant solutions to your problem. Commented Dec 3, 2021 at 5:00

1 Answer 1

1

You could install an alternative JDK, for example Liberica or Corretto, which contain an OpenJFX-Distribution.

Sign up to request clarification or add additional context in comments.

8 Comments

Thanks for the input, but using an alternative JDK is not an option for me. I should have mentioned it in the question.
Then probably, you might need to download the OpenJFX package manually (via cURL for example) and extract its lib-content into $JAVA_HOME/lib and bin-content to $JAVA_HOME/bin of course. That should do the trick eventually. However, that's kinda error prune, since you would need to have that download link up to date inside of your Dockerfile or shell scripts. Another approach might be to download it to your host and let docker build copy it to the correct destinations.
What you'd want to do is described here. You basically want to download a distribution vom gluonhq.com depending on your operating system and you are good to go. You could also get the OpenJFX-JARs from Maven, but you'd have to look at the platform, too. No way around that of course. (However Docker is always linux arm or amd64). Benefit of gluonhq distribution is for example added source code.
Sometimes when addressing comments, I find it useful to edit the question, quote the text of the comment in the question and write the response there rather than in the comment field. Then you get unlimited-length responses and retain full editing and formatting options, which you don't get in comments, as well as usually improving the answer quality. Just a suggestion.
Have a look at repo1.maven.org/maven2/org/openjfx/javafx-graphics/15.0.1 . That's the repository entry for 15.0.1-javafx-graphics. The JARs exists with several classifiers. Aside from sources and javadoc, you also have JARs for win, mac and linux. As said, for Linux, you always need the ones with the linux classifier.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.