6

I'm working on a javaFX project, and I want to compile it in the terminal using maven, but I can't get it to work. It compiles just fine in IntelliJ, but not when I'm in the terminal. I'm using a compile script to run it. I'm using an M2 MacBook Air.

This is my Java version:

openjdk 19.0.1 2022-10-18
OpenJDK Runtime Environment Zulu19.30+11-CA (build 19.0.1+10)
OpenJDK 64-Bit Server VM Zulu19.30+11-CA (build 19.0.1+10, mixed mode, sharing)

Maven version:

Maven home: /opt/homebrew/Cellar/maven/3.8.6/libexec
Java version: 19.0.1, vendor: Homebrew, runtime: /opt/homebrew/Cellar/openjdk/19.0.1/libexec/openjdk.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "13.0.1", arch: "aarch64", family: "mac"

P.S. I'm new to maven, and this is my first post on stack overflow. Any tips are appreciated.

Here's the script:

1 #!/bin/bash -ex  
2
3 mvn -q -e clean
4 mvn -q -e compile
5 mvn -q -e exec:java

Here's the stack trace:

Nov 30, 2022 10:41:30 AM com.sun.javafx.application.PlatformImpl startup
WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @56d120f3'
init() called
2022-11-30 10:41:30.934 java[34735:3292918] *** Assertion failure in -[_NSTrackingAreaAKViewHelper removeTrackingRect:], _NSTrackingAreaAKManager.m:1585
2022-11-30 10:41:30.936 java[34735:3292918] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '0x0 is an invalid NSTrackingRectTag. Common possible reasons for this are: 1. already removed this trackingRectTag, 2. Truncated the NSTrackingRectTag to 32bit at some point.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001809bc418 __exceptionPreprocess + 176
    1   libobjc.A.dylib                     0x0000000180506ea8 objc_exception_throw + 60
    2   Foundation                          0x00000001818fca60 -[NSCalendarDate initWithCoder:] + 0
    3   AppKit                              0x000000018414bf98 -[_NSTrackingAreaAKViewHelper removeTrackingRect:] + 200
    4   libglass.dylib                      0x000000012cc65e80 Java_com_sun_glass_ui_mac_MacApplication__1getMacKey + 3456
    5   libglass.dylib                      0x000000012cc6a540 Java_com_sun_glass_ui_mac_MacApplication__1getMacKey + 21568
    6   AppKit                              0x0000000183bd1ba4 -[NSView setFrame:] + 304
    7   libglass.dylib                      0x000000012cc6a5a0 Java_com_sun_glass_ui_mac_MacApplication__1getMacKey + 21664
    8   AppKit                              0x0000000183bdfad4 -[NSView resizeWithOldSuperviewSize:] + 508
    9   AppKit                              0x0000000183bdf4c4 -[NSView resizeSubviewsWithOldSize:] + 360
    10  AppKit                              0x0000000183bc3acc -[NSView setFrameSize:] + 1120
    11  AppKit                              0x0000000183bd1ba4 -[NSView setFrame:] + 304
    12  AppKit                              0x0000000183bdfad4 -[NSView resizeWithOldSuperviewSize:] + 508
    13  AppKit                              0x0000000183bdf4c4 -[NSView resizeSubviewsWithOldSize:] + 360
    14  AppKit                              0x0000000183bc3acc -[NSView setFrameSize:] + 1120
    15  AppKit                              0x0000000183bde130 -[NSThemeFrame setFrameSize:] + 244
    16  AppKit                              0x0000000183bdda7c -[NSWindow _oldPlaceWindow:fromServer:] + 540
    17  AppKit                              0x0000000183bdcb8c -[NSWindow _setFrameCommon:display:fromServer:] + 1824
    18  libglass.dylib                      0x000000012cc5d700 getImage + 5228
    19  libglass.dylib                      0x000000012cc74274 Java_com_sun_glass_ui_mac_MacWindow__1setBounds2 + 416
    20  ???                                 0x0000000114044aac 0x0 + 4630792876
    21  ???                                 0x0000000114041548 0x0 + 4630779208
    22  ???                                 0x0000000114041548 0x0 + 4630779208
    23  ???                                 0x0000000114041548 0x0 + 4630779208
    24  ???                                 0x0000000114041a88 0x0 + 4630780552
    25  ???                                 0x0000000114041548 0x0 + 4630779208
    26  ???                                 0x0000000114041548 0x0 + 4630779208
    27  ???                                 0x0000000114041548 0x0 + 4630779208
    28  ???                                 0x0000000114041548 0x0 + 4630779208
    29  ???                                 0x0000000114041548 0x0 + 4630779208
    30  ???                                 0x0000000114041548 0x0 + 4630779208
    31  ???                                 0x0000000114041548 0x0 + 4630779208
    32  ???                                 0x0000000114041548 0x0 + 4630779208
    33  ???                                 0x0000000114041548 0x0 + 4630779208
    34  ???                                 0x0000000114041548 0x0 + 4630779208
    35  ???                                 0x0000000114041548 0x0 + 4630779208
    36  ???                                 0x0000000114041a88 0x0 + 4630780552
    37  ???                                 0x0000000114041548 0x0 + 4630779208
    38  ???                                 0x0000000114041a88 0x0 + 4630780552
    39  ???                                 0x0000000114041300 0x0 + 4630778624
    40  ???                                 0x000000010cd3a564 0x0 + 4510164324
    41  ???                                 0x0000000114041300 0x0 + 4630778624
    42  ???                                 0x0000000114041548 0x0 + 4630779208
    43  ???                                 0x0000000114041a88 0x0 + 4630780552
    44  ???                                 0x0000000114030140 0x0 + 4630708544
    45  libjvm.dylib                        0x0000000103e5dd34 _ZN9JavaCalls11call_helperEP9JavaValueRK12methodHandleP17JavaCallArgumentsP10JavaThread + 564
    46  libjvm.dylib                        0x0000000103eb3c9c _ZL20jni_invoke_nonstaticP7JNIEnv_P9JavaValueP8_jobject11JNICallTypeP10_jmethodIDP18JNI_ArgumentPusherP10JavaThread + 536
    47  libjvm.dylib                        0x0000000103eb77c4 jni_CallVoidMethod + 224
    48  libglass.dylib                      0x000000012cc619e8 JNI_OnLoad + 204
    49  Foundation                          0x0000000181864b30 __NSThreadPerformPerform + 264
    50  CoreFoundation                      0x0000000180941a34 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
    51  CoreFoundation                      0x00000001809419c8 __CFRunLoopDoSource0 + 176
    52  CoreFoundation                      0x0000000180941738 __CFRunLoopDoSources0 + 244
    53  CoreFoundation                      0x000000018094033c __CFRunLoopRun + 836
    54  CoreFoundation                      0x000000018093f8a4 CFRunLoopRunSpecific + 612
    55  HIToolbox                           0x0000000189fb33bc RunCurrentEventLoopInMode + 292
    56  HIToolbox                           0x0000000189fb3200 ReceiveNextEventCommon + 672
    57  HIToolbox                           0x0000000189fb2f48 _BlockUntilNextEventMatchingListInModeWithFilter + 72
    58  AppKit                              0x0000000183b98630 _DPSNextEvent + 632
    59  AppKit                              0x0000000183b977c0 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 728
    60  AppKit                              0x0000000183b8bbf0 -[NSApplication run] + 464
    61  libglass.dylib                      0x000000012cc63b70 JNI_OnLoad + 8788
    62  Foundation                          0x0000000181864b30 __NSThreadPerformPerform + 264
    63  CoreFoundation                      0x0000000180941a34 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
    64  CoreFoundation                      0x00000001809419c8 __CFRunLoopDoSource0 + 176
    65  CoreFoundation                      0x0000000180941738 __CFRunLoopDoSources0 + 244
    66  CoreFoundation                      0x000000018094033c __CFRunLoopRun + 836
    67  CoreFoundation                      0x000000018093f8a4 CFRunLoopRunSpecific + 612
    68  libjli.dylib                        0x0000000102ab7094 CreateExecutionEnvironment + 400
    69  libjli.dylib                        0x0000000102ab3794 JLI_Launch + 1208
    70  java                                0x00000001029fbbbc main + 392
    71  dyld                                0x0000000180537e50 start + 2544
)
libc++abi: terminating with uncaught exception of type NSException
Drew
  • 29,895
  • 7
  • 74
  • 104
cupias
  • 61
  • 3
  • 1
    As you have installed a JavaFX SDK, see [_Getting Started with JavaFX: Run HelloWorld using JavaFX SDK_](https://openjfx.io/openjfx-docs/#install-javafx), for [example](https://stackoverflow.com/a/71288497/230513). – trashgod Nov 30 '22 at 18:19
  • 2
    But you are using Maven, so, I'd advise uninstalling the SDK and using maven to fetch the JavaFX modules as dependencies. Such a configuration leads to a simpler, easier-to-maintain system. There is information on that approach as well at the link trashgod provided. Use a recent JavaFX version 19+, as some older versions don't include M2 support or the M2 support in them is buggy. Ensure you aren't shading the jar (including JavaFX classes in the output jar). Don't have a main class that invokes the JavaFX application, have the JavaFX application implements main. – jewelsea Nov 30 '22 at 18:37
  • If configured correctly, you will not receive this warning: *"WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @56d120f3'"* – jewelsea Nov 30 '22 at 18:39
  • I have the same exact issue (same machine, same error), it did work just fine before I did a software update, maybe this information can give some insight? – Plegeus Dec 03 '22 at 10:34
  • @Plegeus really? Were you able to get it fixed? I've just been running my maven projects through IntelliJ for now. – cupias Dec 11 '22 at 09:26
  • @jewelsea, thanks for the tip. I might give this a shot. – cupias Dec 11 '22 at 09:27
  • This problem has to do with JDKs built with macOS SDK 13. Described [here](https://bugs.openjdk.org/browse/JDK-8296654) -- hopefully will be fixed soon. – m0squito Dec 28 '22 at 21:50
  • @m0squito, thanks, I'll keep running my projects through IntelliJ for now. I hope patch is released. – cupias Dec 29 '22 at 00:13
  • I did not fix it, though somebody suggested updating java and stuff... – Plegeus Dec 31 '22 at 21:50

1 Answers1

1

This is fixed in JDK 19.0.2 (I could reproduce the problem with JDK 19.0.1):

$ java -version
openjdk version "19.0.2" 2023-01-17
OpenJDK Runtime Environment (build 19.0.2+7-44)
OpenJDK 64-Bit Server VM (build 19.0.2+7-44, mixed mode, sharing)
$ uname -a
Darwin Juanans-MacBook-Air.local 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct  9 20:15:52 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T8112 arm64

Just download the latest JDK (19.0.2) - you can download it from IntelliJ JDK settings - and export the new JAVA_HOME:

$ export JAVA_HOME=/Users/juanan/Library/Java/JavaVirtualMachines/openjdk-19.0.2/Contents/Home

Double check that your mvn executable is using the latest JDK:

$ mvn --version
Apache Maven 3.8.7 (b89d5959fcde851dcb1c8946a785a163f14e1e29)
Maven home: /opt/homebrew/Cellar/maven/3.8.7/libexec
Java version: 19.0.2, vendor: Oracle Corporation, runtime: /Users/juanan/Library/Java/JavaVirtualMachines/openjdk-19.0.2/Contents/Home
Default locale: en_ES, platform encoding: UTF-8
OS name: "mac os x", version: "13.0.1", arch: "aarch64", family: "mac"

And run you mvn script (javafx:run in my case):

$ mvn javafx:run

enter image description here

Juanan
  • 1,385
  • 11
  • 26
  • 1
    Yep, I was able to get it fixed by changing my pom.xml to use a newer version of open jfx. – cupias Feb 06 '23 at 17:28