我正在用Java制作Xj3D测试文件,并且有一个文件可以与一个名为test.x3dtest.x3dv的X3D和X3DV文件一起使用,该文件是相同的文件,只是两种不同的格式,并且它是一个红色正方形。但是,当我尝试放入自己的X3D文件时,出现以下运行时错误

run:
Mar 20, 2016 12:11:30 PM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
Message: WARNING: antialiasing will be disabled because the   DefaultGLCapabilitiesChooser didn't supply it
Mar 20, 2016 12:11:32 PM org.odejava.Odejava <clinit>
SEVERE: Native code library (32 and 64 bit library) failed to load: java.lang.UnsatisfiedLinkError: no odejava in java.library.path
java.lang.UnsatisfiedLinkError: no odejava in java.library.path
Warning: The class that you specificed for the physics manager is not a  valid instance of PhysicsManager
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1864)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)
    at org.odejava.Odejava.<clinit>(Odejava.java:103)
    at org.xj3d.impl.core.eventmodel.DefaultRigidBodyPhysicsManager$1.run(DefaultRigidBodyPhysicsManager.java:149)
    at org.xj3d.impl.core.eventmodel.DefaultRigidBodyPhysicsManager$1.run(DefaultRigidBodyPhysicsManager.java:142)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.xj3d.impl.core.eventmodel.DefaultRigidBodyPhysicsManager.<clinit>(DefaultRigidBodyPhysicsManager.java:141)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at org.web3d.vrml.renderer.ogl.browser.OGLBrowserCanvas$4.run(OGLBrowserCanvas.java:1069)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.web3d.vrml.renderer.ogl.browser.OGLBrowserCanvas.loadClass(OGLBrowserCanvas.java:1064)
    at org.web3d.vrml.renderer.ogl.browser.OGLBrowserCanvas.initialize(OGLBrowserCanvas.java:694)
    at org.xj3d.ui.awt.browser.ogl.BrowserJPanel.<init>(BrowserJPanel.java:256)
    at org.xj3d.ui.awt.browser.ogl.X3DBrowserJPanel.<init>(X3DBrowserJPanel.java:75)
    at org.xj3d.ui.awt.browser.ogl.X3DOGLBrowserFactoryImpl.createComponent(X3DOGLBrowserFactoryImpl.java:219)
    at org.web3d.x3d.sai.BrowserFactory.createX3DComponent(BrowserFactory.java:263)
    at xj3dtest.Xj3DTest.<init>(Xj3DTest.java:42)
    at xj3dtest.Xj3DTest.main(Xj3DTest.java:56)

Message: Device found: Mouse-0
Message: Device found: Keyboard-0
Exception in thread "main" org.web3d.vrml.lang.UnsupportedNodeException: Request for a node that is not part of the specified profile and components for this stream: viewpoint
    at org.web3d.vrml.renderer.DefaultNodeFactory.createVRMLNode(DefaultNodeFactory.java:730)
    at org.web3d.vrml.renderer.ogl.OGLMainSceneBuilder.startNode(OGLMainSceneBuilder.java:147)
    at org.web3d.vrml.renderer.ogl.OGLVRMLSceneBuilder.startNode(OGLVRMLSceneBuilder.java:514)
    at org.web3d.x3d.jaxp.X3DSAVAdapter.startElement(X3DSAVAdapter.java:830)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1364)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2787)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
    at org.web3d.parser.GeneralisedReader.parse(GeneralisedReader.java:261)
    at org.xj3d.impl.core.loading.DefaultWorldLoader.loadNow(DefaultWorldLoader.java:156)
    at org.xj3d.impl.core.loading.DefaultWorldLoader.loadNow(DefaultWorldLoader.java:203)
    at org.web3d.vrml.scripting.browser.X3DCommonBrowser.createX3DFromURL(X3DCommonBrowser.java:264)
    at  org.web3d.vrml.scripting.external.sai.SAIBrowser.createX3DFromURL(SAIBrowser.java:843)
    at xj3dtest.Xj3DTest.<init>(Xj3DTest.java:50)
    at xj3dtest.Xj3DTest.main(Xj3DTest.java:56)


我的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.xj3d.ui.awt.browser.ogl.X3DOGLBrowserFactoryImpl");
        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[]   {"hafodty_circle1.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);
    }
}


我正在使用Netbeans对此进行编程,并且在Xj3DTest项目中保存了hafodty_circle1.x3dhafodty_circle1.x3dv。我知道在使用test.x3dtest.x3dv运行代码时遇到运行时错误,但是当这些文件中包含其他x3d文件时,我得到了这些文件的输出,而在运行代码时却没有得到任何输出。对这个错误的任何帮助都将非常重要,谢谢。

编辑2016年1月4日

在项目属性中,在运行菜单中,然后在虚拟机选项中。我有以下内容:

java -Djava.library.path="C:\Users\matt\Documents\NetBeansProjects\natives\Windows_10\amd64"

java -Djava.library.path="C:\Users\matt\Documents\NetBeansProjects\natives\Windows_10\x86_64"


因为我不知道应该使用哪个odejava64.dll。现在,当我运行项目时,出现以下错误:

Error: Could not find or load main class java
C:\Users\matt\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 0 seconds)


executor-snippets中是:

<?xml version="1.0" encoding="UTF-8"?>
    <project name="{0} (run)" default="run" basedir=".">
    <target name="run">
        <translate-classpath classpath="${classpath}" targetProperty="classpath-translated" />
        <property name="run.jvmargs" value="" />
        <property name="work.dir" value="${basedir}"/>
        <property name="application.args" value="" />
        <property name="java.failonerror" value="true"/>
        <java classpath="${classpath-translated}" classname="${classname}" dir="${work.dir}" jvm="${platform.java}" fork="true" failonerror="${java.failonerror}">
            <jvmarg value="-Dfile.encoding=${encoding}"/>
            <redirector inputencoding="${encoding}" outputencoding="${encoding}" errorencoding="${encoding}"/>
            <jvmarg line="${run.jvmargs}" />
            <arg line="${application.args}" />
            <syspropertyset>
                <propertyref prefix="run-sys-prop."/>
                <mapper from="run-sys-prop.*" to="*" type="glob"/>
            </syspropertyset>
        </java>
    </target>
</project>

最佳答案

错误UnsatisfiedLinkError表示您缺少本机库(如果在Windows上运行,则为odejava.dll),或者您将32位Java与64位本机库一起使用,反之亦然。

确保将系统属性java.library.path设置为包含本机库的目录,并确保Java运行时环境的“位数”与本机库相同(均为32位或全部为64位)。

您在运行程序时使用java.library.path命令行选项设置-D属性。例如,如果odejava.dll在目录C:\MyProject\lib中:

java -Djava.library.path=C:\MyProject\lib com.myproject.MyMainClass

07-24 21:03