Jogl / Java3D with Java 11 ?

classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

Jogl / Java3D with Java 11 ?

DonPearson
I admit to being confused -- but I am retired and still trying to keep some of Java3D apps alive.  About a year ago, I was able to transition from use of Java3D to using JOGAMP jar files and get my applications working with Java 1.8.  I use Netbeans for building and developing the distributable.     For Java 11,  we no longer are able to use the app along with a JRE (more specifically I would like to transition to using modules and have a standalone app).  It appears that the latest JOGAMP jar files are still 2015.   Has anyone modified them to include a module statement in the jar file?   Perhaps I don't have this quite correct, but I do want to step up to Java11 and have standalone apps.   Any insight would be appreciated.  

Reply | Threaded
Open this post in threaded view
|

Re: Jogl / Java3D with Java 11 ?

gouessej
Administrator
Hello

Please can you tell me which version of Java3D you use (be very accurate)? JOGL 2.4 will be released when it's done (big kudos to Sven by the way, Super Ken was replaced by Super Sven a long time ago ;) ). Anyway, the latest versions of Java3D provided by the JogAmp community still work fine with JOGL 2.3.2 currently. Don't worry about the few warnings and it will be addressed when we release a version with some fixes specifically for Java 11 and later.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Jogl / Java3D with Java 11 ?

DonPearson
Good question actually!   There is no release number on it.  The directory has an 2015-10-09 timestamp on it, and I downloaded it last July (2018).   I tried to find a version number but could not.  

Here is some more info on work I did yesterday:  I can get my application to work with JogAmp in Netbeans11 using JDK1.8.  Looking at the classpath for that project, I have jogamp-fat.jar and j3dcore,j3dutils, and vecmath.jar listed.  All works.  I then recreated a separate project to use JDK11.  My own application code now exists in modules (no actual source code changes) and I use that in my new project.    To get that JDK11 project to be able to compile, I moved the 4 jar files above from the classpath to the module path, and my module-info file now shows them as required (i.e. automatic modules?).  The application then succesfully builds (although jLink apparently doesn't work with automatic modules).  When I go to run, I get the following error:

StarChart3Dpanel constructor scene has been created
StarChart3Dpanel constructor : create simple Universe
java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 1
        at jogamp.fat/jogamp.opengl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationImpl(WindowsAWTWGLGraphicsConfigurationFactory.java:171)
        at jogamp.fat/com.jogamp.nativewindow.GraphicsConfigurationFactory.chooseGraphicsConfiguration(GraphicsConfigurationFactory.java:424)
        at j3dcore/javax.media.j3d.JoglPipeline.createAwtGraphicsConfiguration(JoglPipeline.java:8643)
        at j3dcore/javax.media.j3d.JoglPipeline.getBestConfiguration(JoglPipeline.java:8375)
        at j3dcore/javax.media.j3d.Renderer.doWork(Renderer.java:496)
        at j3dcore/javax.media.j3d.J3dThread.run(J3dThread.java:271)

DefaultRenderingErrorListener.errorOccurred:
GRAPHICS_CONFIG_ERROR: Renderer: Error in GraphicsConfigTemplate3D.getBestConfiguration()
graphicsDevice = D3DGraphicsDevice[screen=0]
Exception in thread "main" java.lang.NullPointerException: Canvas3D: null GraphicsConfiguration
        at j3dcore/javax.media.j3d.Canvas3D.checkForValidGraphicsConfig(Canvas3D.java:943)
        at j3dcore/javax.media.j3d.Canvas3D.<init>(Canvas3D.java:986)
        at j3dutils/com.sun.j3d.utils.universe.Viewer.<init>(Viewer.java:205)
        at j3dutils/com.sun.j3d.utils.universe.Viewer.<init>(Viewer.java:151)
        at j3dutils/com.sun.j3d.utils.universe.SimpleUniverse.<init>(SimpleUniverse.java:249)
        at j3dutils/com.sun.j3d.utils.universe.SimpleUniverse.<init>(SimpleUniverse.java:211)
        at j3dutils/com.sun.j3d.utils.universe.SimpleUniverse.<init>(SimpleUniverse.java:96)
        at StarChart3D/starChart3D.StarChart3Dpanel.<init>(StarChart3Dpanel.java:78)
        at StarChart3D/starChart3D.StarChart3DmainFrame.<init>(StarChart3DmainFrame.java:64)
        at StarChart3D/starChart3D.StarChart3Dapp.<init>(StarChart3Dapp.java:26)
        at StarChart3D/starChart3D.StarChart3Dapp.main(StarChart3Dapp.java:53)
C:\Users\Don\AppData\Local\NetBeans\Cache\11.0\executor-snippets\run.xml:111: The following error occurred while executing this line:
C:\Users\Don\AppData\Local\NetBeans\Cache\11.0\executor-snippets\run.xml:40: Java returned: 1
BUILD FAILED (total time: 15 seconds)

Note: here is the code snippet around the error:

    System.out.println("StarChart3Dpanel constructor : create simple Universe");
    SimpleUniverse su = new SimpleUniverse();
    System.out.println("StarChart3Dpanel constructor :  simple Universe created");

To me, it is interesting that it the same identical application code around the same jar file, but gets different results.   So I need to first figure out what is going on here before worrying about the jLink distribution part. Any help you can provide would be appreciated.  You were extremely helpful to me a year ago just stepping up to JogAmp.
Reply | Threaded
Open this post in threaded view
|

Re: Jogl / Java3D with Java 11 ?

DonPearson
In reply to this post by gouessej
Also, if it helps, I just set up a separate sailing 3D simulation that executes correctly in Netbeans with JDK1.8 but fails in run-time with JDK11 -- with the exact same failure mode:  trying to construct a new SimpleUniverse.   Same error message.  

Reply | Threaded
Open this post in threaded view
|

Re: Jogl / Java3D with Java 11 ?

gouessej
Administrator
Please look at this bug report, I suggested a workaround:
https://jogamp.org/bugzilla/show_bug.cgi?id=1317

You can't use Java 11 without some changes.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Jogl / Java3D with Java 11 ?

DonPearson
Thanks.  Appreciate it.  Somewhat comforting to know that others have seen this same problem -- "not just me".   I will review the workaround and see what I can do.  
Reply | Threaded
Open this post in threaded view
|

Re: Jogl / Java3D with Java 11 ?

DonPearson
In reply to this post by gouessej
PS - not sure where in Netbeans 11 to add those statements....  

--add-exports=java.base/java.lang=ALL-UNNAMED
--add-exports=java.desktop/sun.awt=ALL-UNNAMED
--add-exports=java.desktop/sun.java2d=ALL-UNNAMED

I thought maybe under Project..properties..compiler options?

I tried process options with 3 statements, each with key = exports and value = rest of each lines above.  
Compiles fine, but still gives runtime error same as before.

Also tried copy/pasting it under additional compiler options.  Again, no success.  

If you have used netbeans, a hint would help me :)
Reply | Threaded
Open this post in threaded view
|

Re: Jogl / Java3D with Java 11 ?

gouessej
Administrator
It's in Project Properties -> Run -> VM Options. I use Netbeans 8.2 sometimes. In my humble opinion, you should test those options outside of your IDE first in order to confirm that it works in a lighter context and then please test my suggestion with your IDE. I think that it's simpler to split problems into smaller ones and an IDE is only a time saver, any developer should know how to use the command line interfaces.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Jogl / Java3D with Java 11 ?

DonPearson
Again, thanks.   I tried it in the Run..VM options box yesterday (and again today).  And I see the following warning  before the program starts to run.  The program then begins to run but terminates at the same location when I am trying to create a Simple Universe, giveing me the same error on index out of range.

run:
WARNING: Unknown module: ALL-UNNAMED
--add-exports=java.desktop/sun.awt=ALL-UNNAMED
--add-exports=java.desktop/sun.java2d=ALL-UNNAMED specified to --add-exports


I will of course take your advice and run it outside of Netbeans in the next day or two and see if that helps.  These are just options on the java execution command line is what I am gathering.  

Reply | Threaded
Open this post in threaded view
|

Re: Jogl / Java3D with Java 11 ?

gouessej
Administrator
Can you try without '='?
--add-exports java.base/java.lang=ALL-UNNAMED
--add-exports java.desktop/sun.awt=ALL-UNNAMED
--add-exports java.desktop/sun.java2d=ALL-UNNAMED
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Jogl / Java3D with Java 11 ?

DonPearson
yes, tried that in Netbeans (run..VM options) and get:

run:
WARNING: Unknown module: ALL-UNNAMED
--add-exports specified to --add-exports
Error: Could not find or load main class java.desktop.sun.awt=ALL-UNNAMED
--add-exports
Caused by: java.lang.ClassNotFoundException: java.desktop.sun.awt=ALL-UNNAMED
--add-exports
C:\Users\Don\AppData\Local\NetBeans\Cache\11.0\executor-snippets\run.xml:111: The following error occurred while executing this line:
C:\Users\Don\AppData\Local\NetBeans\Cache\11.0\executor-snippets\run.xml:40: Java returned: 1
BUILD FAILED (total time: 3 seconds)

I currently have lib/jogamp-fat.jar, lib/j3dcar.jar, lib/j3dutils.jar, and lib/vectmath.jar in the modulepath, hoping to make  them into automatic modules.  
Reply | Threaded
Open this post in threaded view
|

Re: Jogl / Java3D with Java 11 ?

gouessej
Administrator
You shouldn't have to put these JARs into the module path, just use the classpath.

You should try to run your program in command line first before solving your problem in Netbeans. It seems to expect the main class somewhere and it wrongly interprets the VM options.

Look at this:
http://forum.jogamp.org/hi-can-jogl-2-3-2-run-with-jdk9-or-jdk10-0-2-tp4039140p4039154.html
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Jogl / Java3D with Java 11 ?

gouessej
Administrator
In reply to this post by DonPearson
I've just tried to run my game (which uses JOGL) with Java11 and this works:
java -jar tuer.jar

This works too:
java -jar tuer.jar --add-exports java.base/java.lang=ALL-UNNAMED --add-exports java.desktop/sun.awt=ALL-UNNAMED --add-exports java.desktop/sun.java2d=ALL-UNNAMED

I use a single fat JAR. As you use multiple JARs, you mustn't use the "-jar" option, you have to use "-cp" with the classpath instead.

--add-exports might be useful to compile your source code and to run your program, --add-opens might be useful to run your program.

Your bug only occurs under Windows whereas I'm under GNU Linux at home. I'll try under Microsoft Windows 10 in a few days but I'm almost sure that my second command line still works, I tested it under Windows 10 but with Java 9.

Maybe you could add the exports into module-info.jar but I'm not sure that it would work.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Jogl / Java3D with Java 11 ?

DonPearson
Thanks Julien.   I need a couple of days before I can get back to working on this problem, but will try several of the recommendations you have made.  
Reply | Threaded
Open this post in threaded view
|

Re: Jogl / Java3D with Java 11 ?

DonPearson
In reply to this post by gouessej
Well I did make some progress today!  While working outside of Netbeans, it became apparent that I was still missing a classpath to the jogamp.fat-all jar file.  The only way I could get Netbeans to successfully compile all the files was to promote j3dutils.jar, j3dcore.jar, and vecmath.jar to the Modulepath, leaving jogamp-fat.jar on the classpath.  The software then compiled succesfully.  ( i never could get it to compile successfully with the 4 jar files above left just on the classpath).  By adding -cp jogamp-fat.jar to the VM options for run, the application actually came up and ran successfully!  So at least now, I have a fully functioning application with Java11 -- at least in Netbeans.  

I get the following warnings, but at least the app is fully functional:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.jogamp.common.os.NativeLibrary$3 (file:/C:/projects/extLib/JogAmp/jogamp-fat-all/jogamp-fat/jogamp-fat.jar) to method java.lang.ClassLoader.findLibrary(java.lang.String)
WARNING: Please consider reporting this to the maintainers of com.jogamp.common.os.NativeLibrary$3
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

It won't allow use of jLink for distribution though, so now I still have to figure out how to bundle it for external use.  I have read a bit about jdep to understand dependencies, but don't think that will get me where I need to go to have a fully functioning external package.  

Also, I should note that I have not incorporated the -add exports... statements yet. That may be part of in the intermediary steps as I go forward.  

But for today, I will stay happy and know that it all works in Netbeans with Java11.
Reply | Threaded
Open this post in threaded view
|

Re: Jogl / Java3D with Java 11 ?

DonPearson
In reply to this post by gouessej
Oops -besides the reply I just made in the past hour, I did notice one small bit of erroneous functionality: when running Java11, I have lost the middle mouse button functionality that exists with the same code running under Java8.  That functionality was used to zoom with the mouse:

//Set up ZOOMing behavior around TG3.
    MouseZoom mouseZoom = new MouseZoom(); //CENTER BUTTON (or ALT-leftButton)
    mouseZoom.setTransformGroup(tg3);
    mouseZoom.setSchedulingBounds(bs);
    tg3.addChild(mouseZoom);
    mouseZoom.setFactor(0.001);
    //System.out.println("mouseZoom");

Reply | Threaded
Open this post in threaded view
|

Re: Jogl / Java3D with Java 11 ?

DonPearson
In reply to this post by gouessej
I was able to get the program to run outside of Netbeans with the following commands  --so another step has been successfully completed:

java -cp C:\projects\extLib\JogAmp\jogamp-fat-all\jogamp-fat\jogamp-fat.jar;  -p C:\projects\NasaPiscesLib\dist

\nasaPiscesLib.jar;C:\projects\GeneralLib\dist\generalLib.jar;C:\projects\StarChartNew\dist\StarChart.jar;C:\projects

\StarChart3DNew\lib\j3dutils.jar;C:\projects\StarChart3DNew\lib\vecmath.jar;C:\projects\StarChart3DNew\lib\j3dcore.jar;C:

\projects\StarChart3DNew\dist\StarChart3D.jar -m StarChart3D/starChart3D.StarChart3Dapp -add-exports java.base/java.lang=ALL-

UNNAMED --add-exports java.desktop/sun.awt=ALL-UNNAMED --add-exports java.desktop/sun.java2d=ALL-UNNAMED


As expected, the mouseZoom function (center mouse wheel) still doesn't work.  

So I still have a question: this method of deployment still requires the target PC to have Java11 JDK installed on it, correct? Otherwise it will not recognize the java command.  My goal is to be able to run this on windows machines without requiring Java installation.  
Reply | Threaded
Open this post in threaded view
|

Re: Jogl / Java3D with Java 11 ?

DonPearson
In reply to this post by gouessej
A little bit more insight into the MouseZoom anomaly:  in JDK8, my software works as expected: the left mouse button is programmed and works as expected,  the center mouse button also works as expected, and the right mouse button is not programmed, and works like expected (i.e. it does nothing).    The JDK11 version of the software has all three buttons behaving as if they were the left button. I was able to move the code snippet for the center mouse over to the MouseWheelZooom class and now it behaves as programmed.  All of these mouse classes come from javax.media.j3d.SceneGraphObject -- so something must have changed up at that level in javax to cause the anomalous functioning of the center and right mouse buttons.

Reply | Threaded
Open this post in threaded view
|

Re: Jogl / Java3D with Java 11 ?

gouessej
Administrator
In reply to this post by DonPearson
Those warnings will disappear in the future as the root cause is known.

I have my own tool to run a Java program without relying on the JRE installed on the system.

Please report this bug against Java3D. Maybe Phil can help you.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Jogl / Java3D with Java 11 ?

DonPearson
thanks.  I just now reported the bug to the Java3D section of the forum.