Login  Register

Getting Java3d to work on OS X on IntelliJ

Posted by Zahand on Oct 20, 2014; 6:40am
URL: https://forum.jogamp.org/Getting-Java3d-to-work-on-OS-X-on-IntelliJ-tp4033405.html

So I have ben trying to get Java3D to work on IntelliJ so I can do the mandatory assignments for class (Studying Computer Science). But I have had some problems. (Here is a copy of the stackoverflow post I made: http://stackoverflow.com/questions/26378249/how-to-get-java3d-to-work-in-intellij-on-os-x?noredirect=1)


I use IntelliJ as my IDE and it works great for Java and Python. But I am struggling to make it work for Java3D.

I've tried using my google-fu but to no avail. So I am coming here for some guidance. I have tried multiple tutorials/guides, here is what I have tried:


The code I am trying to run is from http://www.java3d.org/starting.html


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

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

    import javax.media.j3d.BranchGroup;

    public class Hello3d {

        public Hello3d(){

        SimpleUniverse universe = new SimpleUniverse();

        BranchGroup group = new BranchGroup();

        group.addChild(new ColorCube(0.3));

        universe.getViewingPlatform().setNominalViewingTransform();

        universe.addBranchGraph(group);

        }

    public static void main( String[] args ) {

        new Hello3d();

        }

    }


First thing I tried was installing the Java3d Jar's and adding them to the dependencies: (I got them from: http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-java-client-419417.html#java3d-1.5.1-oth-JPR

But I got the error:

    Exception in thread "J3D-Renderer-1" java.lang.NoClassDefFoundError: apple/awt/ComponentModel
            at com.sun.opengl.impl.JAWT_DrawingSurface.GetDrawingSurfaceInfo0(Native Method)
    at com.sun.opengl.impl.JAWT_DrawingSurface.GetDrawingSurfaceInfo(JAWT_DrawingSurface.java:56)
            at com.sun.opengl.impl.macosx.MacOSXOnscreenGLDrawable$1.run(MacOSXOnscreenGLDrawable.java:165)
    at java.security.AccessController.doPrivileged(Native Method)
            at  com.sun.opengl.impl.macosx.MacOSXOnscreenGLDrawable.lockSurface(MacOSXOnscreenGLDrawable.java:163)
    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)
    Caused by: java.lang.ClassNotFoundException: apple.awt.ComponentModel
            at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
            at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 11 more

Then I learned that java3d is already installed on mac and I did the same. I added the jars to my dependencies. But I got the same error.


My last attempt was to follow this guide: http://gouessej.wordpress.com/2012/08/01/java-3d-est-de-retour-java-3d-is-back/ 

I downloaded the jars, put them all in the same folder and added them to my dependencies. But, again, I got the same error.


Now, it might be all my fault (I am not sure if I have to add them to my dependencies then add new Jars, but it always worked when I added different kind of API's) or it might be something more complex. Hopefully some of you guys have encountered the same issues and can help me.

Thanks in advance.

----------------


Edit: After trying what gouessej said, I got this error:

    JavaVM WARNING: JAWT_GetAWT must be called after loading a JVM
    AWT not found
    Exception in thread "main" java.lang.NoClassDefFoundError: apple/awt/CGraphicsDevice
    at javax.media.j3d.GraphicsConfigTemplate3D.<clinit>(GraphicsConfigTemplate3D.java:55)
    at com.sun.j3d.utils.universe.SimpleUniverse.getPreferredConfiguration(SimpleUniverse.java:368)
    at com.sun.j3d.utils.universe.Viewer.<init>(Viewer.java:348)
    at com.sun.j3d.utils.universe.Viewer.<init>(Viewer.java:298)
    at com.sun.j3d.utils.universe.SimpleUniverse.<init>(SimpleUniverse.java:215)
    at com.sun.j3d.utils.universe.SimpleUniverse.<init>(SimpleUniverse.java:177)
    at com.sun.j3d.utils.universe.SimpleUniverse.<init>(SimpleUniverse.java:88)
    at MAIN.<init>(MAIN.java:22)
    at MAIN.main(MAIN.java:41)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
    Caused by: java.lang.ClassNotFoundException: apple.awt.CGraphicsDevice
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
            ... 14 more