kpmais Member Licensed User Longtime User Mar 31, 2025 #1 Hi everyone. To convert centimeters to pixels, I use the following routine: B4X: Expand Collapse Copy Private Sub GetPixelProCm As Int Dim jo As JavaObject jo.InitializeStatic("java.awt.Toolkit") jo = jo.RunMethod("getDefaultToolkit",Null) Return Floor(jo.RunMethod("getScreenResolution",Null)/2.18) End Sub This works fine with OpenJDK 14.x. However, with OpenJDK 19.x, I get the following error when running: java.lang.IllegalAccessException: class anywheresoftware.b4j.object.JavaObject cannot access class sun.awt.windows.WToolkit (in module java.desktop) because module java.desktop does not export sun.awt.windows to unnamed module @6224ccc0 at B4X: Expand Collapse Copy jo.RunMethod("getScreenResolution",Null) I have not found any indication that the awt.toolkit has changed in openjdk 19.x. Can anyone help me? Many thanks to the readers.
Hi everyone. To convert centimeters to pixels, I use the following routine: B4X: Expand Collapse Copy Private Sub GetPixelProCm As Int Dim jo As JavaObject jo.InitializeStatic("java.awt.Toolkit") jo = jo.RunMethod("getDefaultToolkit",Null) Return Floor(jo.RunMethod("getScreenResolution",Null)/2.18) End Sub This works fine with OpenJDK 14.x. However, with OpenJDK 19.x, I get the following error when running: java.lang.IllegalAccessException: class anywheresoftware.b4j.object.JavaObject cannot access class sun.awt.windows.WToolkit (in module java.desktop) because module java.desktop does not export sun.awt.windows to unnamed module @6224ccc0 at B4X: Expand Collapse Copy jo.RunMethod("getScreenResolution",Null) I have not found any indication that the awt.toolkit has changed in openjdk 19.x. Can anyone help me? Many thanks to the readers.
Daestrum Expert Licensed User Longtime User Mar 31, 2025 #2 Add (Tested in Java 23) B4X: Expand Collapse Copy #VirtualMachineArgs: --add-exports java.desktop/sun.awt.windows=ALL-UNNAMED Last edited: Mar 31, 2025 Upvote 1
Add (Tested in Java 23) B4X: Expand Collapse Copy #VirtualMachineArgs: --add-exports java.desktop/sun.awt.windows=ALL-UNNAMED
kpmais Member Licensed User Longtime User Mar 31, 2025 #3 C'est formidable !!! Thank you very much. It works!!! I'll have to get into this topic. Thanks again. Upvote 0
C'est formidable !!! Thank you very much. It works!!! I'll have to get into this topic. Thanks again.
kpmais Member Licensed User Longtime User Mar 31, 2025 #4 Sorry, the joy is only partial. It runs fine in debug and release. However, when I produce a standalone app, the error occurs again. I'm using OpenJDK 19.x here as well. I'll try a higher Java version. Upvote 0
Sorry, the joy is only partial. It runs fine in debug and release. However, when I produce a standalone app, the error occurs again. I'm using OpenJDK 19.x here as well. I'll try a higher Java version.
stevel05 Expert Licensed User Longtime User Mar 31, 2025 #5 For the packager you will need to add: B4X: Expand Collapse Copy #PackagerProperty: VMArgs = --add-exports java.desktop/sun.awt.windows=b4j Upvote 0
For the packager you will need to add: B4X: Expand Collapse Copy #PackagerProperty: VMArgs = --add-exports java.desktop/sun.awt.windows=b4j
Daestrum Expert Licensed User Longtime User Mar 31, 2025 #6 just add the similar command to the packager too (Steve beat me to it) Upvote 0
kpmais Member Licensed User Longtime User Mar 31, 2025 #7 Thanks again to both of you. It works now . But why is the assignment "=b4j" and not "=ALL-UNNAMED"? I'm currently puzzling over that. Upvote 0
Thanks again to both of you. It works now . But why is the assignment "=b4j" and not "=ALL-UNNAMED"? I'm currently puzzling over that.
stevel05 Expert Licensed User Longtime User Mar 31, 2025 #8 kpmais said: But why is the assignment "=b4j" and not "=ALL-UNNAMED"? Click to expand... Perplexity can answer that better than me, and it's too long to copy. See it's response here : https://www.perplexity.ai/search/why-when-exporting-virtualmach-UkozsfpOQ3m9_KZszfPsyw You can dismiss the login popup if you don't have an account. Upvote 0
kpmais said: But why is the assignment "=b4j" and not "=ALL-UNNAMED"? Click to expand... Perplexity can answer that better than me, and it's too long to copy. See it's response here : https://www.perplexity.ai/search/why-when-exporting-virtualmach-UkozsfpOQ3m9_KZszfPsyw You can dismiss the login popup if you don't have an account.