Hello,
I'm developing CodeLab IDE & Simulators using Java3D. To remain compatible with other libraries, I need to upgrade to Java 17 (https://adoptium.net/temurin/releases/?version=17), but apparently Java3D is causing compatibility problems. When will a Java3D version compatible with Java17 be available? Thank you for help me! Jerome https://codelab.univ-lemans.fr Caught AppContextInfo(Bug 1004) InaccessibleObjectException: Unable to make public static sun.awt.AppContext sun.awt.AppContext.getAppContext() accessible: module java.desktop does not "exports sun.awt" to unnamed module @4ee22985 on thread J3D-Renderer-1 [0]: java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354) [1]: java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297) [2]: java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199) [3]: java.base/java.lang.reflect.Method.setAccessible(Method.java:193) [4]: com.jogamp.nativewindow.awt.AppContextInfo$1$1.run(AppContextInfo.java:40) [5]: com.jogamp.common.util.UnsafeUtil.doWithoutIllegalAccessLogger(UnsafeUtil.java:219) [6]: com.jogamp.nativewindow.awt.AppContextInfo$1.run(AppContextInfo.java:34) [7]: java.base/java.security.AccessController.doPrivileged(AccessController.java:318) [8]: com.jogamp.nativewindow.awt.AppContextInfo.<clinit>(AppContextInfo.java:31) [9]: com.jogamp.nativewindow.awt.JAWTWindow.<init>(JAWTWindow.java:128) [10]: jogamp.nativewindow.jawt.macosx.MacOSXJAWTWindow.<init>(MacOSXJAWTWindow.java:79) [11]: java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [12]: java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) [13]: java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [14]: java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) [15]: java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480) [16]: jogamp.nativewindow.NativeWindowFactoryImpl.getAWTNativeWindow(NativeWindowFactoryImpl.java:105) [17]: jogamp.nativewindow.NativeWindowFactoryImpl.getNativeWindowImpl(NativeWindowFactoryImpl.java:66) [18]: com.jogamp.nativewindow.NativeWindowFactory.getNativeWindow(NativeWindowFactory.java:654) [19]: org.jogamp.java3d.JoglPipeline$QueryCanvas.addNotify(JoglPipeline.java:8665) [20]: java.desktop/java.awt.Container.addNotify(Container.java:2804) [21]: java.desktop/java.awt.Window.addNotify(Window.java:791) [22]: java.desktop/java.awt.Dialog.addNotify(Dialog.java:770) [23]: java.desktop/java.awt.Dialog.conditionalShow(Dialog.java:917) [24]: java.desktop/java.awt.Dialog.show(Dialog.java:1048) [25]: java.desktop/java.awt.Component.show(Component.java:1728) [26]: java.desktop/java.awt.Component.setVisible(Component.java:1675) [27]: java.desktop/java.awt.Window.setVisible(Window.java:1036) [28]: java.desktop/java.awt.Dialog.setVisible(Dialog.java:1016) [29]: org.jogamp.java3d.JoglPipeline.getBestConfiguration(JoglPipeline.java:8439) [30]: org.jogamp.java3d.Renderer.doWork(Renderer.java:497) [31]: org.jogamp.java3d.J3dThread.run(J3dThread.java:271) |
Administrator
|
As I replied in a private message, you just have to use the usual "--add-opens" clause I mentioned in my tutorial to make it work.
Julien Gouesse | Personal blog | Website
|
In reply to this post by Jerome
In our case, we use the following options when using Java 17.
(Windows) --add-exports=java.desktop/sun.awt=ALL-UNNAMED (Linux) --add-exports=java.desktop/sun.awt=ALL-UNNAMED --add-opens=java.desktop/sun.awt.X11=ALL-UNNAMED By the way, it is unfortunately found that the "--add exports" option is ignored in some Windows systems if it is added in .l4j.ini for Launch4j (an old version), whereas the option works if added to a Windows .bat file. |
Administrator
|
Thank you for the feedback. It's strange, "--add-opens java.desktop/sun.awt=ALL-UNNAMED" was enough to make it work under GNU Linux the last time I tried.
Julien Gouesse | Personal blog | Website
|
Administrator
|
Currently used in master tip
The added one to have background erase working w/ AWT https://jogamp.org/bugzilla//show_bug.cgi?id=1430#c3
|
In reply to this post by gouessej
Hi!
I have the same error/exception => Caught AppContextInfo(Bug 1004) InaccessibleObjectException: Unable to make public static sun.awt.AppContext sun.awt.AppContext.getAppContext() accessible: module java.desktop does not "exports sun.awt" to unnamed module @eb21112 on thread J3D-Renderer-1 As you suggested to OP, I added "‐‐add-opens=java.desktop/sun.awt=ALL-UNNAMED" to the VM arguments in Eclipse IDE 'Run Configurations..." However, this did not work. Now I get: Error: Could not find or load main class ‐‐add-opens=java.desktop.sun.awt=ALL-UNNAMED Caused by: java.lang.ClassNotFoundException: ‐‐add-opens=java.desktop.sun.awt=ALL-UNNAMED It appears it's trying to load the VM arguments as a class...?!?!??!? WTF? What am I missing? I'm using: MacOS Big Sur Eclipse 4.33 Java SDK 23 JOGL 2.5.0 Java3D 1.7.1 |
Administrator
|
Hello
As far as I can tell, Eclipse seems to generate the command line by placing the arguments in the wrong order, it doesn't mean that Eclipse has a bug but maybe there's something wrong in your project. You can probably reproduce your problem in command line by inverting the main class and the --add-opens clause. How do you specify the main class? P.S: Please indicate how you fill the "Main" and the "Arguments" tabs.
Julien Gouesse | Personal blog | Website
|
Thanks for your response Julien.
The main class is Demo.LightingExample The program arguments are blank. The VM arguments are ‐‐add-opens=java.desktop.sun.awt=ALL-UNNAMED Here is my full command line generated by Eclipse (with the —add-opens option): /Library/Java/JavaVirtualMachines/jdk-23.jdk/Contents/Home/bin/java ‐‐add-opens=java.desktop.sun.awt=ALL-UNNAMED -Dfile.encoding=UTF-8 -Dstdout.encoding=UTF-8 -Dstderr.encoding=UTF-8 -p /Library/Java/Extensions -classpath /Users/andrew/Documents/eclipse-workspace/3D Stuff/bin:/Users/andrew/Miscellaneous JARS/vrml97.jar:/Users/andrew/Documents/eclipse-workspace/JOGL/bin:/Users/andrew/Documents/eclipse-workspace/JOGL/lib/gluegen-rt.jar:/Users/andrew/Documents/eclipse-workspace/JOGL/lib/gluegen-rt-natives-macosx-universal.jar:/Users/andrew/Documents/eclipse-workspace/JOGL/lib/jogl-all.jar:/Users/andrew/Documents/eclipse-workspace/JOGL/lib/jogl-all-natives-macosx-universal.jar:/Users/andrew/Documents/eclipse-workspace/Java3D/bin:/Users/andrew/Documents/eclipse-workspace/Java3D/lib/java3d-core.jar:/Users/andrew/Documents/eclipse-workspace/Java3D/lib/java3d-utils.jar:/Users/andrew/Documents/eclipse-workspace/Java3D/lib/vecmath.jar Demo.LightingExample This raises the ClassNotFoundException when executing both in Eclipse and from the command line. Error: Could not find or load main class ‐‐add-opens=java.desktop.sun.awt=ALL-UNNAMED Caused by: java.lang.ClassNotFoundException: ‐‐add-opens=java.desktop.sun.awt=ALL-UNNAMED If I don't include the —add-opens option, the program appears to run (including the 3D components) but I get several exceptions: AppContextInfo(Bug 1004) InaccessibleObjectException: Unable to make public static sun.awt.AppContext sun.awt.AppContext.getAppContext() accessible: module java.desktop does not "exports sun.awt" to unnamed module @eb21112 on thread J3D-Renderer-1 Here is the command line without the —add-opens option: /Library/Java/JavaVirtualMachines/jdk-23.jdk/Contents/Home/bin/java -Dfile.encoding=UTF-8 -Dstdout.encoding=UTF-8 -Dstderr.encoding=UTF-8 -p /Library/Java/Extensions -classpath /Users/andrew/Documents/eclipse-workspace/3D Stuff/bin:/Users/andrew/Miscellaneous JARS/vrml97.jar:/Users/andrew/Documents/eclipse-workspace/JOGL/bin:/Users/andrew/Documents/eclipse-workspace/JOGL/lib/gluegen-rt.jar:/Users/andrew/Documents/eclipse-workspace/JOGL/lib/gluegen-rt-natives-macosx-universal.jar:/Users/andrew/Documents/eclipse-workspace/JOGL/lib/jogl-all.jar:/Users/andrew/Documents/eclipse-workspace/JOGL/lib/jogl-all-natives-macosx-universal.jar:/Users/andrew/Documents/eclipse-workspace/Java3D/bin:/Users/andrew/Documents/eclipse-workspace/Java3D/lib/java3d-core.jar:/Users/andrew/Documents/eclipse-workspace/Java3D/lib/java3d-utils.jar:/Users/andrew/Documents/eclipse-workspace/Java3D/lib/vecmath.jar Demo.LightingExample Note that when I execute in the command line I have to add " marks around classpath... Any idea what's going on? |
Administrator
|
You're welcome, thank you for your detailed information.
At first, the extension mechanism has been removed from Java a long time ago and your version of Java doesn't support it, -p is a shortcut of --module-path and JogAmp's Java has never been an extension and shouldn't be mixed with an old version of Java3D installed as an extension. It will probably not be enough to solve your problem but you shouldn't use "-p /Library/Java/Extensions". Secondly, your version of Java uses UTF-8 by default on all operating systems, "-Dfile.encoding=UTF-8 -Dstdout.encoding=UTF-8 -Dstderr.encoding=UTF-8" is useless too in this case. Thirdly, either avoid spaces in directory names or escape them correctly, i.e "3D Stuff" and "Miscellaneous JARS". Yes you have to add " marks around the classpath because of these spaces. Maybe Eclipse doesn't do that correctly. Fourthly, you can simplify your classpath by using jogamp-all.jar instead of separate JogAmp JARs. Moreover, there is no need to put bin/ into the classpath, don't confuse the classpath with the library path. If you don't want to change too much things, remove the spaces from your directory names, update your Eclipse run configuration to take this change into account, try again with --add-opens and if it still fails to work, try to remove the useless stuff I mentioned. This should work: /Library/Java/JavaVirtualMachines/jdk-23.jdk/Contents/Home/bin/java ‐‐add-opens=java.desktop.sun.awt=ALL-UNNAMED -classpath /Users/andrew/Documents/eclipse-workspace/3D\ Stuff/bin:/Users/andrew/Miscellaneous\ JARS/vrml97.jar:/Users/andrew/Documents/eclipse-workspace/JOGL/bin:/Users/andrew/Documents/eclipse-workspace/JOGL/lib/gluegen-rt.jar:/Users/andrew/Documents/eclipse-workspace/JOGL/lib/gluegen-rt-natives-macosx-universal.jar:/Users/andrew/Documents/eclipse-workspace/JOGL/lib/jogl-all.jar:/Users/andrew/Documents/eclipse-workspace/JOGL/lib/jogl-all-natives-macosx-universal.jar:/Users/andrew/Documents/eclipse-workspace/Java3D/bin:/Users/andrew/Documents/eclipse-workspace/Java3D/lib/java3d-core.jar:/Users/andrew/Documents/eclipse-workspace/Java3D/lib/java3d-utils.jar:/Users/andrew/Documents/eclipse-workspace/Java3D/lib/vecmath.jar Demo.LightingExample
Julien Gouesse | Personal blog | Website
|
Ok, I removed all the unnecessary stuff and renamed 3D Stuff to 3D_Stuff...
No change. Still get Error: Could not find or load main class ‐‐add-opens=java.desktop.sun.awt=ALL-UNNAMED So I wondered if the —add-opens option need to be AFTER the -classpath option...? Tried this but now I get: Error occurred during initialization of boot layer java.lang.RuntimeException: Unable to parse --add-opens <module>/<package>: java.desktop.sun.awt I had to change the order of the —add-opens option on the command line because Eclipse always places it first before the classpath. Not sure whether you can change it in Eclipse. I take it that this is an issue introduced by Java 9..? |
Free forum by Nabble | Edit this page |