Why does JavaFX not work under OpenJDK 17 from Homebrew? - java

After installing both the OpenJDK and the Temurin casks (testing out first one, then the other), I'm still getting errors like these when running a simple example javafx app from the terminal:
Example.java:1: error: package javafx.application does not exist
It seems to me like JavaFX is not included in OpenJDK for macOS, at least the Homebrew versions, but it should be.
The version I'm installing is 17, on both counts.
What can I do to fix this? (I specifically don't want to install Oracle's JDK, to avoid hefty future licensing fees or potential litigation, which Oracle is known for.)

JavaFX has never been an official part of the Java platform.
For a while, Oracle was bundling the JavaFX libraries with their own Oracle JDK product, but later stopped. Those libraries were a bonus, an extra, not required by the Java specifications.
Keep in mind that several vendors provide Java implementations. At least two of them provide a variant that includes the OpenJFX libraries implementing JavaFX, if that is what you want:
ZuluFX by Azul Systems
LibericaFX from BellSoft
Last time I looked, both of those products were available for macOS on both Intel Macs and Apple Silicon Macs.
Alternatively, you can bundle the OpenJFX libraries within your app.

Related

When will AdoptOpenJDK 11 come for Apple with M1 chip?

I am using a MacBook Air with the M1 chip.
I tried Zulu JDK for M1 for development, and it works, however it does not work with OpenJFX. I have narrowed down the problem using Zulu vs AdoptOpenJDK.
Does anyone have any idea when OpenJDK will be compatible with the M1 chip?
Java 17, shipped 2021-09
There is an official sub-project on the OpenJDK project for porting to the Apple Silicon hardware, JEP 391: macOS/AArch64 Port.
That work is done, built for Java 17, delivered in September of 2021.
The Apple Silicon port benefits from work done on the Windows on ARM port. That work is done, delivered in Java 16. Previous to that, Linux on ARM support was added to Java 9.
👉 So Java 17 for macOS on Apple Silicon (AArch64, ARM) Macs is available now.
Update: Java 18 is now available too, as is early access Java 19.
You can choose from a variety of vendors to obtain an installer/binary. Off the top of my head, those may include Azul Systems, SAP, BellSoft, Amazon, Microsoft, Adoptium (formerly AdoptOpenJDK), Oracle, Red Hat/IBM, Pivotal, and perhaps more.
Regarding JavaFX, at least two of those vendors, Azul Systems and BellSoft, offer an edition of their JDK product that bundles the OpenJFX libraries. That may be of interest to you, as an alternative to adding the libraries to your app.
If you need further assistance with that Azul product, you can purchase support from that company. Or post a Question here with the detailed specifics of your JavaFX work and its point of failure on Apple Silicon. Ideally, provide a minimal example of code demonstrating the problem.
Earlier Java
Some of those vendors listed above have back-ported earlier versions of Java (Java 8, Java 11, maybe others) to macOS on Apple Silicon. That work is not an official part of the OpenJDK project support for Apple Silicon, only Java 17+ is.
Adoptium recently (2022-Oct-22) released Java 11 that supports Apple Silicon:
https://adoptium.net/temurin/releases/?version=11
And for a summary of supported platforms:
https://adoptium.net/supported-platforms/

who is the distributor of openjdk docker image

my understanding is you need to have a distributor to use openjdk someone like (oracle openjdk, adoptopenjdk) but on docker repo for openjdk how do I find out who is the distributor if I just use their reference documentation
{the code below in copied from openjdk official docker repo}
FROM openjdk:11
COPY . /usr/src/myapp
WORKDIR /usr/src/myapp
RUN javac Main.java
CMD ["java", "Main"]
moving from java 8 to java 11
It's all written there on the docker page: https://hub.docker.com/_/openjdk/
openjdk:<version>
This is the defacto image. [...] These are the suite
code names for releases of Debian and indicate which release the image
is based on. [...]
openjdk:<version> (from 12 onwards), [...]
Starting with openjdk:12
the default image as well as the -oracle and -oraclelinux7 variants
are based on the official Oracle Linux 7 image which is provided under
the GPLv2 as per the Oracle Linux End User Agreement (EULA). [...]
TL;DR: the images are maintained by the Docker community, versions < 12 ship the OpenJDK build from Debian or Alpine Linux, later versions ship the Oracle builds.
By the way, until Version including 8, the Oracle JDK was more freely available. Anyway, Linux distributions built their own binaries. The binary distributions by AdoptOpenJDK, Amazon Corretto, etc. are only there, because Oracle doesn't provide binary builds freely anymore. But you can download OpenJDK and build it yourself, if you like.
Edit: You could also ssh into the image and run java -version
Edit2: Java 7 and support
I want to address your comment on my answer. You specifically asked for Java version 7. This version is quite old (first release in 2011!) and you will not find any long term support for without paying for commercial support. Period.
This version also predates the license changes to Oracle binaries, so the whole AdoptOpenJDK argument doesn't matter.
On the OpenJDK Docker Hub page, you can see different images shipping Java 7 builds, some with Alpine Linux and some with Debian Jessie. Those are - presumably, I've only verified that for Debian - builds of the open source OpenJDK project by that distribution. So the GPL with classpath exception should be the license that applies (read: you can use it commercially).
Note that even the LTS-support for Debian Jessie ends next month: https://wiki.debian.org/LTS
That shouldn't be necessarily a problem, depending on where you want to run that image (i.e., facing the public internet vs. private intranet).
If you have to stick with such an old version of Java, you have few options (maybe taking a modern linux image and build OpenJDK yourself [that will be painful, I imagine]).
Edit3: Recent version 7 support and v8+ from AdoptOpenJdk
OK, so you clarified in your comment, that you are not actually looking for version 7 builds.
I did, however, find an up-to-date and supported build of Java 7, by Azul: https://hub.docker.com/r/azul/zulu-openjdk
But you said you're running version 8, looking to go to 11. Then I would highly recommend AdoptOpenJDK, which is currently the most popular build. They offer Docker images as well (Note: they offer different JVMs: Hotspot is the default and highly recommended, OpenJ9 is based on a development by IBM)

Licensing, updates for OpenJDK distribution from Fedora

What is the source for the OpenJDK RPMs found in Fedora distributions?
Is it safe to count on Fedora's RPMs for Java for commercial use with long term support?
Neither Oracle nor RedHat licensing seem to be necessary.
What is the source for the OpenJDK rpms found in Fedora distributions?
It's OpenJDK, which is supported.
Is it safe to count on Fedora's rpms for Java for commercial use with long term support?
If you're using an LTS version, yes.
OpenJDK Support from AdoptOpenJdk
OpenJDK support form RedHat
What is the source for the OpenJDK RPMs found in Fedora distributions?
You can use Fedora's tools on Fedora to get the sources: fedpkg clone java-11-openjdk; cd java-11-opendjk; fedpkg prep and you should end up with a directory containing the entire set of (modified) sources for OpenJDK 11.
You can also grab a source rpm (.src.rpm) from an OpenJDK build in Fedora, such as https://koji.fedoraproject.org/koji/buildinfo?buildID=1350114. That source rpm contains an archive of the entire set of sources used in Fedora.
This script is actually used to generate the source archive: https://src.fedoraproject.org/rpms/java-11-openjdk/blob/master/f/generate_source_tarball.sh. If you take a look at it, you can see that it basically grabs sources from the OpenJDK 11 Updates Project itself: http://hg.openjdk.java.net/jdk-updates/jdk11u/
Is it safe to count on Fedora's RPMs for Java for commercial use with long term support? Neither Oracle nor RedHat licensing seem to be necessary.
There's a couple of parts to this answer:
You can definitely use the Fedora packages for whatever task you want, including any commercial tasks. Fedora and OpenJDK are Free Software. They don't restrict your usage.
You definitely don't need a license from Red Hat (or Oracle) to use OpenJDK and Fedora.
If you want support, Fedora is probably the wrong place to look. Fedora is basically self-supported. Red Hat pays developers to work on OpenJDK try and fix issues as they come up. But there's no support or priority guarantees of any sort in Fedora (even if the same developers are active in both). If something breaks, you can only ask the community to help. Support (and priority in addressing bugs) is a major part of Red Hat's value proposition. That said, the developers who work on Fedora RPMs generally do a really good job.
Fedora is definitely not a Long Term Supported release. Fedora releases go out of support (meaning no more security updates for OpenJDK, unless you upgrade to a newer version of Fedora) in a year or so. If you care about a stable (as in, unchanging base), Fedora is probably the wrong tool for the job. If you want to use Fedora, you will have to upgrade every year or so, or you will lose access to security updates in OpenJDK (among other components).
If you care about long term stability and don't want to go down a RHEL route, I would suggest looking at CentOS. It has some of the same downsides as Fedora (no real support, bugs may take some time to be resolved, security updates may not be as quick) but it is maintained by the community for a longer time.
If you just care about OpenJDK binaries on non-Fedora platforms I would also suggest looking at:
OpenJDK binaries from the official OpenJDK 8 and 11 projects: https://adoptopenjdk.net/upstream.html
AdoptOpenJDK binaries built by the community: https://adoptopenjdk.net/index.html
A number of other companies, groups and organizations provide OpenJDK builds that they maintain. I can't really speak about them.
(Disclaimer: I work at Red Hat. I used to work in the team that maintains OpenJDK for Fedora but I work in a different team now.)

Where to find required JRE files in OpenJDK for an JavaFX application to be wrapped using Launch4j

I'm building a GUI application in Java using JavaFX. So far I've been using Oracle JDK but due to licensing issues, I've decided to move on to OpenJDK or Azul Zulu. They don't come with JavaFX so I built OpenJFX myself on Ubuntu 16.04 (running on WSL).
Now, to wrap the application using Launch4j, I need the only the required JRE files to keep the application size minimum. In Oracle JDK distributions JRE is simply found in JRE folder, however, OpenJDK and OpenJFX have a different structure and I could not find (or missed, my bad) any documentation relevant to my question.
tl;dr: Need the location/path of minimum of required JRE files from OpenJDK and OpenJFX to wrap a cross-platform application using Lanuch4j.

Changes required to migrate from Oracle JDK to OpenJDK

We are planning to migrate our project from Oracle JDK to OpenJDK. I have some questions regarding the same.
After doing some analysis I found that OpenJDK will have a feature release every 6 months which is only supported until the next feature release.It's essentially a continuous stream of releases targeted to developers. Now my question is will it be a good idea to migrate to OpenJDK. Because if the
above statement is correct then we need to upgrade OpenJDK in our application every 6 months
Ref : Differences between Oracle JDK and OpenJDK
What are the basic changes required to do this migration. When I say basic changes, I mean I need to understand in very high level.One thing I know that is
Oracle JDK and Open JDK are having different jar licences. So do I need to replace all Oracle JDK jars with OpenJDK jars as its mentioned in
Migrating to OpenJDK from Oracle JDK ?
Currently we are using :
JDK 1.8
Tomcat 8
Windows Operating System for development. Services gets deployed in linux OS
Maven Build tool
Appreciate your help.
Thanks
Now my question is will it be a good idea to migrate to OpenJDK
For Java 11 you might want to, though by Java 11 they will be almost identical.
So do I need to replace all Oracle JDK jars with OpenJDK jars
I would install a version of OpenJDK and use the JARs which came with it. I wouldn't mix and match them.
JDK 1.8
I am not sure gain anything by migrating Java 8. Oracle Java 8 is still supported at least until Jan 2019. After that, you might not get any update, but you might not with OpenJDK either.
If your concern is getting support for Java 8, I suggest contacting a company which will give commercial support Java 8 such as Azul for what seemed like a reasonable price. https://www.azul.com/downloads/zulu/zulu-windows/

Categories

Resources