java.lang.NoClassDefFoundError: javafx/geometry/Point3D

@ctrueden @haesleinhuepf
Since today, I am getting a class not found error in Fiji when using javafx.geometry.Point3D. It runs without problems in IntelliJ, but not within Fiji.
Do you have an idea how to fix this?
(I think I had that issue before but do not remember the solution…)

[EDIT]: I was only depending on one small class of javafx so I could get rid of the dependency altogether. Thus, no real need for help, but still curious why it used to work and now doesn’t anymore (could also be that I, by mistake, changed something in some pom…)

1 Like

Are you running this code with OpenJDK 8? Fiji standalone with its own Java?

If both answers yes, this is probably the cause: OpenJDK 8 does not ship with JavaFX and you have to install it manually (usually through package mangers of the operating system). I assume that you did install JavaFX through your operating system and the jdk you are using in IntelliJ is aware of this installation but the Fiji jdk is not. Try running Fiji with the system jdk instead and see if that works.

Also, if you are not using JavaFX for your GUI, I would not recommend using classes from it at all.

3 Likes

That was my solution, in fact. I just was using the Point3D class :slight_smile:

2 Likes

Hello Christian and Philipp -

Your post and Philipp’s reply are confusing to me.

I have a downloaded, auto-updated version of FIji, and I can use
it to run a script that uses javafx.geometry.Point3D:

from javafx.geometry import Point3D
p3d = Point3D (1.1, 2.2, 3.3)
print p3d

This script runs without error and prints:

Point3D [x = 1.1, y = 2.2, z = 3.3]

This is running:
ImageJ 2.0.0-rc-69/1.52n; Java 1.8.0_66 [64-bit]; Linux 4.4.0-148-generic;

(It is the case that I have another copy of openjdk on my system,
but Fiji shouldn’t know about it, and I redid my test with that copy
of openjdk “hidden” with the same result.)

This script also runs the same on a separate copy of Fiji I keep
that I updated to ImageJ 2.0.0-rc-69/1.52o using
Help > Update ImageJ....
So my naive conclusion is that my copy of Fiji shipped / ships with
javafx.

Thanks, mm

2 Likes

I can confirm @mountain_man’s observation and also:

$ find Fiji.app -name '*fx*'
Fiji.app/java/linux-amd64/jdk1.8.0_172/jre/lib/amd64/libjavafx_font_pango.so
Fiji.app/java/linux-amd64/jdk1.8.0_172/jre/lib/amd64/libjavafx_font_t2k.so
Fiji.app/java/linux-amd64/jdk1.8.0_172/jre/lib/amd64/libjfxmedia.so
Fiji.app/java/linux-amd64/jdk1.8.0_172/jre/lib/amd64/libjavafx_font_freetype.so
Fiji.app/java/linux-amd64/jdk1.8.0_172/jre/lib/amd64/libfxplugins.so
Fiji.app/java/linux-amd64/jdk1.8.0_172/jre/lib/amd64/libjavafx_iio.so
Fiji.app/java/linux-amd64/jdk1.8.0_172/jre/lib/amd64/libjfxwebkit.so
Fiji.app/java/linux-amd64/jdk1.8.0_172/jre/lib/amd64/libjavafx_font.so
Fiji.app/java/linux-amd64/jdk1.8.0_172/jre/lib/ext/jfxrt.jar
Fiji.app/java/linux-amd64/jdk1.8.0_172/jre/lib/jfxswt.jar
Fiji.app/java/linux-amd64/jdk1.8.0_172/jre/lib/javafx.properties

Could you dop the same for your Fiji.app directory @Christian_Tischer?

Update: I removed my system-wide JavaFX before I tried with Fiji and it still worked (so it does not use that one).

Hello Philipp -

Just to confirm, I see essentially the same thing as you when I
run find *fx* on my Fiji installation. (I get jdk1.8.0_66, rather than
jdk1.8.0_172.)

Also, I get no *fx* hits when I run find on my separate openjdk
installation.

Thanks, mm

1 Like

Thanks for digging into this. I have a Mac. and for me:

find /Applications/Fiji.app -name '*jdk*'
/Applications/Fiji.app/java/macosx/adoptopenjdk-8.jdk
find /Applications/Fiji.app -name '*fx*'

The latter giving nothing. Thus either there is some difference between the Mac and the Linux distributions or my Fiji is somehow screwed up (which is also always a possibility :-).

AdoptOpenJDK 8 doesn’t contain JavaFX: https://github.com/AdoptOpenJDK/openjdk-build/issues/577

As I understand it, JavaFX was a separate installation in the early days, then became part of Java 8 (at least the Oracle distribution), then left again in Java 11 (or thereabouts) and now finds a home on Maven Central. But I have a strong suspicion that these JavaFX 11 maven artefacts are not compatible with Java 8.

Given the Java licensing changes, the fact that OpenJDK 8 distributions don’t (yet?) contain JavaFX seems… troublesome. Furthermore, I wasn’t able to track down pre-built 32-bit versions of JavaFX, which is the main reason QuPath is 64-bit only.

So while I like JavaFX a lot, this: :point_down:

1 Like

Yes, I tested a while ago and it is not byte-code compatible. Java >= 10 is required if I remember correctly. We are currently restricted to Java 8 for our software but updating our software stack to Java 10 (or later) is on the agenda, and JavaFX Maven artifacts are one of the reasons.

1 Like

As others have pointed out: OpenJDK does not include JavaFX.

I recently (within the past couple of months, IIRC) and hastily updated the macOS version of Fiji to ship with AdoptOpenJDK 8 instead of Oracle’s Java. This was mostly in an attempt to address this problem:

But also for licensing reasons, since looking forward, we need to ship Fiji with OpenJDK and not Oracle’s Java. And also to ship a JDK rather than a JRE, so that the Script Editor works out of the box with Java code, instead of giving cryptic errors—see e.g.:

I am planning to update Windows and Linux also to ship with OpenJDK. When that happens, JavaFX will stop working. The planned solution to avoid this is to update ImageJ, Fiji and friends to Java 11, since as mentioned JavaFX can be shipped as regular Java libraries with Java 11, and therefore distributed on ImageJ update sites rather than being part of the bundled Java itself.

It may be awhile longer before we can update to Java 11, though, and in the meantime, a couple of Fiji plugins relying on JavaFX are currently therefore broken on macOS. So in the shorter term, I was thinking about exploring including OpenJFX 8 into the bundled AdoptOpenJDK that we ship with Fiji. Would people find this helpful? If so, does anyone have the bandwidth to test it themselves by installing OpenJFX 8 into Fiji’s bundled Java across all of Windows, macOS and Linux?

3 Likes