JAVA3D Universe problem

Sorry to bother but i have a problem with my code. You see something is wrong with my Applet. Every time I try to run the code this error start to pop up in the console. Java3D is an API I am using for 3D graphics.

The error:
java.lang.UnsatisfiedLinkError: no j3dcore-ogl in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at javax.media.j3d.NativePipeline$1.run(NativePipeline.java:231)
at java.security.AccessController.doPrivileged(Native Method)
at javax.media.j3d.NativePipeline.loadLibrary(NativePipeline.java:200)
at javax.media.j3d.NativePipeline.loadLibraries(NativePipeline.java:157)
at javax.media.j3d.MasterControl.loadLibraries(MasterControl.java:987)
at javax.media.j3d.VirtualUniverse.(VirtualUniverse.java:299)
at javax.media.j3d.Canvas3D.(Canvas3D.java:3881)
at Code.MainGamePanel.(MainGamePanel.java:14)
at Code.MainWindow.(MainWindow.java:8)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

MainWindow.java



package Code;

import java.applet.*;
import java.awt.*;

public class MainWindow extends Applet{
	private static final long serialVersionUID = 1L;
	MainGamePanel mgpanel = new MainGamePanel();
	private static int FWIDTH = 800;
	private static int FHEIGHT = 500;
	public void init(){
		setName("Dimensions");
		add(mgpanel);
		setSize(FWIDTH,FHEIGHT);
		setBackground(Color.white);
	}
	public void start(){}
	public void stop(){}
	public void destroy(){}
}


MainGamePanel.java This is where the problem is.



package Code;

import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.*;
import javax.media.j3d.*;
import javax.swing.*;
import java.awt.*;

public class MainGamePanel extends JPanel{
	private static final long serialVersionUID = 1L;
	SimpleUniverse universe;
	public MainGamePanel(){
		setLayout(new BorderLayout());
		Canvas3D canvas = new Canvas3D(universe.getPreferredConfiguration());
		add("Center",canvas);
		universe = new SimpleUniverse(canvas);
		BranchGroup scene = createSceneGraph();
		universe.getViewingPlatform().setNominalViewingTransform();
		scene.compile();
		universe.addBranchGraph(scene);
	}
	public BranchGroup createSceneGraph(){
		BranchGroup Bgroup = new BranchGroup();
		ColorCube cube = new ColorCube(0.5f);
		Bgroup.addChild(cube);
		return Bgroup;
	}
}



That error has nothing to do with your code. You just didn’t include the natives in the java.library.path correctly.

Also, Java3D is dead and I recommend that you abandon it too. There are many superior alternatives like Java Monkey Engine, jPCT, and Ardor3D.

I had the SAME exact problem less than a hour ago.

Make sure you’ve added all the 3 .jar files from the Java3D folder in : (“C:\Program Files\Java\Java3D\1.5.2\bin”) (“j3dcore.jar", “j3dutils.jar”, "vecmath.jar”).

Not going to write out a little tutorial for that because it’s all over the internet, but what they didn’t say (And what I done was):

Go into “C:\Program Files\Java\Java3D\1.5.2\bin” or where ever that path is relative to your machines foldering system, and find the “j3dcore-ogl.dll” in that bin folder, and place it in with the ‘jre#/bin’ folder that you’re IDE (Eclipse/Netbeans) is using as default, mine is “C:\Program Files\Java\jre6\bin”.

NOOOOOOOOOOOOOOOOOOOO!!!

Never put java3d or any other library in the runtime. There will be conflicts when applications embed a different version of the library. Always embed. You have to set -Djava.library.path to point to a where your application has stored the files.