我正在制作一个项目,将X3D
个文件导入Java
并显示它们。但是,当我运行它时,我得到运行时错误
run:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/j3d/Canvas3D
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.web3d.j3d.browser.X3DJ3DBrowserFactoryImpl.createComponent(X3DJ3DBrowserFactoryImpl.java:358)
at org.web3d.x3d.sai.BrowserFactory.createX3DComponent(BrowserFactory.java:263)
at xj3dtest.Xj3DTest.<init>(Xj3DTest.java:42)
at xj3dtest.Xj3DTest.main(Xj3DTest.java:56)
Caused by: java.lang.ClassNotFoundException: javax.media.j3d.Canvas3D
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 16 more
我的Java
代码是
package xj3dtest;
import java.awt.BorderLayout;
import java.awt.Container;
import static java.lang.Boolean.TRUE;
import javax.swing.JFrame;
import org.web3d.x3d.sai.Browser;
import org.web3d.x3d.sai.BrowserFactory;
import org.web3d.x3d.sai.X3DComponent;
import org.web3d.x3d.sai.X3DScene;
import java.util.HashMap;
public class Xj3DTest extends JFrame {
public Xj3DTest(String title) {
super(title);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Setup browser parameters
HashMap requestedParameters=new HashMap();
requestedParameters.put("Antialiased",TRUE);
requestedParameters.put("TextureQuality","medium");
requestedParameters.put("PrimitiveQuality","medium");
requestedParameters.put("Xj3D_InterfaceType","SWING");
requestedParameters.put("Xj3D_NavbarShown",TRUE);
requestedParameters.put("Xj3D_NavbarPosition","TOP");
requestedParameters.put("Xj3D_LocationShown",TRUE);
requestedParameters.put("Xj3D_LocationPosition","TOP");
requestedParameters.put("Xj3D_LocationReadOnly",TRUE);
requestedParameters.put("Xj3D_ShowConsole",TRUE);
requestedParameters.put("Xj3D_OpenButtonShown",TRUE);
requestedParameters.put("Xj3D_ReloadButtonShown",TRUE);
requestedParameters.put("Xj3D_StatusBarShown",TRUE);
requestedParameters.put("Xj3D_FPSShown",TRUE);
requestedParameters.put("Xj3D_ContentDirectory","CurrentDirectory");
requestedParameters.put("Xj3D_AntialiasingQuality","low");
requestedParameters.put("Xj3D_Culling_Mode", "frustum");
System.setProperty("x3d.sai.factory.class", "org.web3d.j3d.browser.X3DJ3DBrowserFactoryImpl");
X3DComponent x3dComponent = BrowserFactory.createX3DComponent(requestedParameters);
Browser browser = x3dComponent.getBrowser();
Container cp = getContentPane();
cp.setLayout(new BorderLayout());
cp.add((javax.swing.JPanel)x3dComponent, BorderLayout.CENTER);
X3DScene scene = browser.createX3DFromURL(new String[] {"test.x3d"});
browser.replaceWorld(scene);
}
public static void main(String[] args) {
Xj3DTest frame = new Xj3DTest("Xj3D test");
frame.setSize(640, 480);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
我所拥有的Jars
:gluegen-rt, gluegen-rt-natives-linux-amd64, gluegen-rt-natives-windows-amd64, gluegen-rt-natives-windows-i586, jhall, joal, joal-natives-linux-amd64, joalnatives-windows-amd64, gluegen-natives-windows-i586, jogl-all, jogl-natives-linux-amd64, jogl-natives-windows-amd64, jogl-natives-windows-i586, xj3d.browser_2.1.0-nps, xj3d.cadfilter_2.1.0-nps, xj3d.replica_2.1.0-nps, xj3d-2.1-3rdparty-nps, xj3d-2.1-nps, xj3d-core, xj3d-j3d
位于名为jar
的文件中。在VM Options
的{{1}}部分的Run
内Jave project
任何帮助都会很棒。