Java运行时错误

时间:2016-03-21 12:49:21

标签: java

我在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文件。对此错误的任何帮助都意味着很多,谢谢。

编辑01/04/2016

在“项目属性”和“运行”菜单中以及“VM选项”中。我有以下内容:

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>

1 个答案:

答案 0 :(得分:2)

此错误UnsatisfiedLinkError表示您缺少本机库(odejava.dll如果您在Windows上运行),或者您正在使用32位Java和64比特本地库,反之亦然。

确保将系统属性java.library.path设置为包含本机库的目录,并确保&#34; bitness&#34;您的Java运行时环境与本机库(32位或64位)相同。

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

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