I've got a Java class that creates a Java3D (1.5.2) Canvas3D, adds some things, rotate it a bit and then saves it as an image - without actually displaying the Canvas3D in a JFrame or similar. That part works fine, based on the Java3D print_canvas3d example.
Unfortunately, the whole thing seems to have troubles cleaning up, because I see two symptoms:
a) After the image is saved, the application should be finished, but it does not exit. Calling System.exit(0) does fix that, but since the class will be used in an application server later, that is not a solution.
b) After the first image is saved, trying to create a second one (by creating a new Canvas3D, etc.) blocks the whole application on GraphicsConfiguration.getDevice() (and, if that is worked around by storing the Device in a static member, on similar places).
So, somehow the cleanup of the Java3D code seems to lack something very important. Unfortunately I can't seem to be able to find that...
I tried the solution given [here], tried to SimpleUniverse.cleanUp, SimpleUniverse.getViewer.getView.attachViewPlatform(null) and other stuff, but nothing seems to change it. The only workaround I found is to place the code inside daemon threads and save the whole Canvas3D part in a static variable, but honestly, that looks more like a mess and not a solution. Unfortunately, I don't have the time left to rewrite the whole thing in JOGL or similar and I also can't simply create an external application to write the image and exit for each call... So I need to know how to do it correctly.
My question is simple: How do I clean up a Java3D application correctly without System.exiting it?
Regards,
Flo