java3d

Answered

Has anyone gotten intellij idea to work with java3d and jdk9?

0
12 comments

Maybe you could share a link to the sample project that doesn't work for you so that others can try it and possibly find the cause/workaround?

0

Hi Serge,

Here is a link to a web start application;

http://www.docjava.com/book/cgij/code/jnlp/j3d.examples.boids.Main.jnlp

As far as that goes, I think it will work if you have jdk8 installed...but, if you try to run it under jdk9, no joy.

With intellij, I use a very simple example;

import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.universe.SimpleUniverse;

import javax.media.j3d.BranchGroup;
import javax.media.j3d.Canvas3D;
import java.awt.*;


public class StillCube  {


    public StillCube() {

        GraphicsConfiguration config =
                SimpleUniverse.getPreferredConfiguration();

        Canvas3D c3d = new Canvas3D(config);


        // SimpleUniverse is a Convenience Utility class
        SimpleUniverse su = new SimpleUniverse(c3d);

        // This will move the ViewPlatform back a bit so the
        // objects in the scene can be viewed.
        su.getViewingPlatform().setNominalViewingTransform();

        su.addBranchGraph(getBranchGroup());
        Frame f = new Frame();
        f.setLayout(new BorderLayout());
        Panel p = new Panel(new BorderLayout());
        p.add(BorderLayout.CENTER, c3d);
        f.add(p, BorderLayout.CENTER);
        f.setSize(200,200);
        f.setVisible(true);
    } // end of HelloJava3Da (constructor)

    public BranchGroup getBranchGroup() {
        // Create the root of the branch graph
        BranchGroup bg = new BranchGroup();
        bg.addChild(new ColorCube(.25));
        bg.compile();

        return bg;
    } // end of CreateSceneGraph method of HelloJava3Da

    //  The following allows this to be run as an application
    //  as well as an applet

    public static void main(String[] args) {
        StillCube cube = new StillCube();


    }

}

This works ok under jdk1.8. with jdk1.9 I get:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.sun.opengl.impl.Java2D$2 (file:/Users/lyon/current/java/j4p/jars/j3d_old/jogl1.5.2/jogl.jar) to field sun.java2d.opengl.OGLUtilities.UNDEFINED
WARNING: Please consider reporting this to the maintainers of com.sun.opengl.impl.Java2D$2
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
Exception in thread "J3D-Renderer-1" java.lang.UnsatisfiedLinkError: /Library/Java/Extensions/libjogl_awt.jnilib: dlopen(/Library/Java/Extensions/libjogl_awt.jnilib, 1): Library not loaded: /System/Library/Frameworks/JavaVM.framework/Libraries/libjawt.dylib
  Referenced from: /Library/Java/Extensions/libjogl_awt.jnilib
  Reason: image not found
    at java.base/java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2614)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2535)
    at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:873)
    at java.base/java.lang.System.loadLibrary(System.java:1857)
    at com.sun.opengl.impl.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:189)
    at com.sun.opengl.impl.NativeLibLoader.access$000(NativeLibLoader.java:49)
    at com.sun.opengl.impl.NativeLibLoader$DefaultAction.loadLibrary(NativeLibLoader.java:80)
    at com.sun.opengl.impl.NativeLibLoader.loadLibrary(NativeLibLoader.java:103)
    at com.sun.opengl.impl.NativeLibLoader.access$200(NativeLibLoader.java:49)
    at com.sun.opengl.impl.NativeLibLoader$2.run(NativeLibLoader.java:132)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at com.sun.opengl.impl.NativeLibLoader.loadAWTImpl(NativeLibLoader.java:118)
    at com.sun.opengl.impl.JAWT.getJAWT(JAWT.java:91)
    at com.sun.opengl.impl.macosx.MacOSXOnscreenGLDrawable.lockSurface(MacOSXOnscreenGLDrawable.java:144)
    at com.sun.opengl.impl.macosx.MacOSXOnscreenGLContext.makeCurrentImpl(MacOSXOnscreenGLContext.java:57)
    at com.sun.opengl.impl.GLContextImpl.makeCurrent(GLContextImpl.java:134)
    at javax.media.j3d.JoglPipeline$QueryCanvas.doQuery(JoglPipeline.java:9049)
    at javax.media.j3d.JoglPipeline.getBestConfiguration(JoglPipeline.java:8797)
    at javax.media.j3d.Renderer.doWork(Renderer.java:514)
    at javax.media.j3d.J3dThread.run(J3dThread.java:275)

 

so I used:

--illegal-access=permit

but that does not do anything that I can detect...

Thanks!
- Doug

0

Do you have /System/Library/Frameworks/JavaVM.framework/Libraries/libjawt.dylib file?

Maybe /Library/Java/Extensions/libjogl_awt.jnilib is referencing it with the hardcoded path on Mac?

For me it works on Windows just fine, I've copied j3dcore-ogl.dll into c:\Program Files\Java\jdk-9\bin\.

Maybe someone more familiar with Java3D on Mac will step in to help you.

0

/System/Library/Frameworks/JavaVM.framework has the contents:

 ls
Frameworks@    JavaVM@        Resources@
Headers@    Modules@    Versions/

This gave me the idea that perhaps install should be to:

/Library/Java/Extensions/ the contents of that directory has:
gluegen-rt.jar        jogl.jar        libjogl_cg.jnilib
j3d-readme/        libgluegen-rt.jnilib    vecmath.jar
j3dcore.jar        libjogl.jnilib
j3dutils.jar        libjogl_awt.jnilib

This is where I find: libjogl_awt.jnilib
Then I thought, perhaps the layout of /System/Library/Frameworks/JavaVM.framework
has changed with the new jdk..
cd /System/Library/Frameworks/JavaVM.framework/Versions/Current/
Commands/        JavaPluginCocoa.bundle/    Resources/
Frameworks/        JavaVM*            _CodeSignature/
Headers/        Modules/
I know nothing about Modules (except that they are optional and that I watched
some youtubers try to explain it).
./Headers/jni.h
./Headers/jni_md.h
./Resources/.compatibility/libIASupport.jnilib
looks like there is a jni remnant here.

Hmm. Looks like a bunch of legacy jdirect stuff; com/apple/mrj/jdirect/
14compatibility.jar    IASupport.jar        libIASupport.jnilib*
Not sure that is the place to be installing stuff.

Itchy head....now scratched.
Thanks for piping in Serge!

I am open to suggestions.
Cheers!
- Doug


0

I'd try to copy libjawt.dylib file from Java 9 to /System/Library/Frameworks/JavaVM.framework/Libraries/,

0

cd /System/Library/Frameworks/JavaVM.framework/Libraries/
/System/Library/Frameworks/JavaVM.framework/Libraries/: No such file or directory.

Didn't the layout of Java change with jdk9 on the mac?

Thanks!

 - Doug

0

Probably java3d expects the old layout, hence the problem. You can create this directory and copy the file there manually to make it happy.

0

Splendid idea. Bit of a hiccup;

pwd
/System/Library/Frameworks/JavaVM.framework
mini{lyon}166: sudo mkdir Libraries
mkdir: Libraries: Operation not permitted

The problem is that El Capitan doesn't allow me to change anything in this folder (not even with "sudo").

The folder is "restricted":

ls -lO
total 40
lrwxr-xr-x  1 root  wheel  restricted  27 Dec 22  2016 Frameworks@ -> Versions/Current/Frameworks
lrwxr-xr-x  1 root  wheel  restricted  24 Jul 21 06:54 Headers@ -> Versions/Current/Headers
lrwxr-xr-x  1 root  wheel  restricted  23 Dec 22  2016 JavaVM@ -> Versions/Current/JavaVM
lrwxr-xr-x  1 root  wheel  restricted  24 Jul 21 06:54 Modules@ -> Versions/Current/Modules
lrwxr-xr-x  1 root  wheel  restricted  26 Dec 22  2016 Resources@ -> Versions/Current/Resources
drwxr-xr-x  4 root  wheel  restricted 136 Dec 22  2016 Versions/

Genius!

"SIP" (System Intregrity Protection) prevents me from harming myself. Swell.

Details on SIP disablement appear below....is this what people normally do to run Java3d? It seems a bit extreme. What will I tell my students?

Thanks!

 - Doug

To make this change:

temporarily disable SIP the following way

  1. reboot
  2. as soon as you hear the "Mac sound" on the grey screen, press Cmd+R to enter Recovery mode
  3. Open Utilities->Terminal
  4. Run the command csrutil disable
  5. Reboot, you'll land in the normal OS with SIP disabled
  6. do all the changes you'd like to do
0

Did it help with java3d after you copied the library?

0

Hi Serge,

The file is just where is should be now...

/System/Library/Frameworks/JavaVM.framework/Libraries
mini{lyon}15: ls
libjawt.dylib*

 file *
libjawt.dylib: Mach-O 64-bit dynamically linked shared library x86_64

I wrote a program to attempt a test:

public static void main(String[] args) {
final String extns = "/Library/Java/Extensions/";
final String libarray[] = {
//"libjawt.dylib",
"libjogl_awt.jnilib"
//"libgluegen-rt.jnilib",
// "libjogl.jnilib",
// "libjogl_cg.jnilib"
};
for (int i=0; i < libarray.length;i++){
final String libFile = extns + libarray[i];
System.out.println("loading:"+libFile);
System.load(libFile);

}

}

The problem:


loading:/Library/Java/Extensions/libjogl_awt.jnilib
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000000114d5b795, pid=770, tid=7171
#
# JRE version: Java(TM) SE Runtime Environment (8.0_51-b16) (build 1.8.0_51-b16)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.51-b03 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C  [libawt_lwawt.dylib+0x44795]  JNI_OnLoad+0x91
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/lyon/current/java/j4p/hs_err_pid770.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

I have a feeling this is a hard problem, libjawt.dylib
may have to be rebuilt from source code.

What could be wrong?
Thanks!
- Doug

 

0

You may contact java3d developers for details. I don't think we can help here.

0
Avatar
Permanently deleted user

It's been 2 years, any update you could give?

Hopefully you see this!

0

Please sign in to leave a comment.