I am currently in the process of trying to deploy my JavaFX application (either with a jar or an installer, however an installer would be preferred). I have seen some sources point to using jlink, in which I have tried to no avail.
While I would have no problem building normally with jlink, I am trying to include a custom serialization utility I made with Maven and Java 17 (no JavaFX, but it is a single modular with a module-info). To import this into my project, I am simply adding it as a dependency. Additionally, this dependency requires SnakeYAML, which I don't believe is a modular project? (Important later)
Now, with this dependency, if I try to run javafx:jlink, I typically get an error like "jlink does not work with automatic modules" (in reference to my serialization utility).
My setup:
JavaFX 17.0.1
JDK 17.0.1
Maven 3.8.4
IntelliJ IDEA ultimate
So, my main two questions:
Should I even bother with jlink, especially if I am trying to get an installer?
With modular projects like my JavaFX project, how do I add dependencies from other modular projects (and also, within the serialization utlity, somehow shade SnakeYAML) and allow them to be compiled with JavaFX?
Should I even bother with jlink, especially if I am trying to get an installer?
No.
You can make use of jlink during the process, but, in my experience, it is not necessary. Also, the images jlink creates can be a little difficult to integrate with what is required by jpackage, which you will need to use anyway.
Instead, use jpackage, not jlink if you want an installer.
jpackage can both link your application and create an installer, but jlink can only link and cannot create an installer.
With modular projects like my JavaFX project, how do I add dependencies from other modular projects (and also, within the serialization utlity, somehow shade SnakeYAML) and allow them to be compiled with JavaFX?
Don’t shade jars when packaging, it is not necessary. Also, if the jars are modular, it will break their modularity and they might not work (for example the JavaFX jars are not supported when shaded into a jar).
To add compile dependencies, you are already using Maven, just use its compile dependency mechanism.
For jar dependencies which you have created yourself, use the Maven install command to install the dependencies into your local repository, or use the install facilities in your repository manager (e.g. jfrog artifactory), if you use one.
The modern maven build process and the IDE integrations (at least Idea anyway) will automatically configure the correct paths for compilation of the declared dependencies so that they are available from the module path if they are modular and the class path or as an automatic module if they are not modular.
Include the dependent jars in your package. This can be done two ways:
if the jars are modular, link the jars into the runtime image included in the package:
Both jlink and jpackage can do this, but when creating an installer, use jpackage for the linking not jlink as jpackage will ensure all files in the image are in the right location for the installer, but jlink will not, in my experience using Java 17 tools.
if the jars are not modular, then include them in a lib directory in the package. In the startup script for your application, which is included in the package, place the lib directory for the non-modular library files on the class path, so that they can be found.
Additionally, this dependency requires SnakeYAML, which I don't believe is a modular project?
Follow the tutorial at:
https://github.com/dlemmermann/JPackageScriptFX
A description of JPackageScriptFX:
demonstrates how projects can use scripts to build self-contained, platform-specific executables and installers of their JavaFX applications via the jdeps, jlink, and jpackage tools
the scripts do not try to create a fully modularized solution but instead try to enable existing projects / applications, which often use non-modularized 3rd party dependencies, to be packaged
I opened a project in NetBeans, it is a Maven-based project and i have a problem with javafx imports. There is a communique f.e.: "package javafx.animation does not exist".
Normally when I create a new JavaFX projekt I select the Java with Ant > Java Aplication and then when I right click on my project on the projects list I choose Properties and in the Libraries section I can add JavaFX library.
In this case, when I open maven-based project there is not Libraries section in the properties and I don't know how to add the JavaFX library?
Instructions for using JavaFX with Maven and Gradle-based projects are found here:
https://openjfx.io/openjfx-docs/
I suspect you are running on a JDK that does not have JavaFX modules included. That is normal. However, there are some builds of OpenJDK that include the JavaFX modules so you don't have to add them manually. Using such a JDK may make things easier.
Consider one of the OpenJDK builds from Azul or Bellsoft that includes JavaFX.
For Bellsoft choose the "Full JDK":
https://bell-sw.com/pages/downloads/
For Azul choose "JDK FX" as the "package":
https://www.azul.com/downloads/zulu-community/?package=jdk
So I've got a simple test app with a Gradle file that bundles JavaFX into the jar such that I can run "java -jar test.jar" from the terminal. It currently specifies 11.0.1 from OpenJFX. Now I can run from IntelliJ using their JBR, which has JavaFX included, but it uses some 10.0.2-internal version I don't want. Of course I could add each module manually via VM options, but ideally I have a solution that doesn't require me to do this for every configuration in all my projects. Really what I want to do is ensure the JFX versions used by IntelliJ and Gradle are the same.
I've tried adding in the JFX modules as Dependencies to my own module, adding them as Global Libraries, even adding the jar's to the SDK via classpath, but none of these solve the "JavaFX runtime components are missing" error. How can I get IntelliJ to match the version of JavaFX in my Gradle file?
I want to embed chrome inside a SWT application. I was trying with JCEF. But not able to succeed.
I came across the following link: How to integrate Chromium Embedded Framework (CEF) with java
But I don't want to use maven as mentioned in step3.
I need a step by step details of how to embed a chrome.
If you can't build JCEF you can use some maven builds and forks like:
GitHub: Pandomium - fork with maven builds and natvies
Maven: JavaCef - clean maven builds
~ I dont want to use maven
Maven just hosts jar files so you can download it and add to your project manually but it's not recommended at all.
Since you're using SWT, I think that you should checkout this: Browser implement Chromium support
This request lead to this project: Chromium for SWT
Currently is working on version 59 of chormium and uses the SWT Browser API.
I have an existing Java project in Netbeans that uses Swing and I would like to start using Java FX 2.0 for some components in that project.
I have dowloaded the latest version of the JDK (1.7.0_03) and enabled JavaFX but when I try adding an import javafx.xxx statement, Netbeans can't resolve the link. Do I need to manually add some JARs to my list of external libraries?
Project Properties use "JDK 1.7-FX Enabled":
which is configured this way:
If you created your project in older NetBeans it can miss libraries from FX enabled plaftorm.
You can:
either recreate the project in NetBeans 7.1+ and copy sources
or include next library to the libs: C:/Program Files/Oracle/JavaFX 2.0 SDK/rt/lib/jfxrt.jar