使用Xj3D时出现Java错误

时间:2016-02-13 17:51:05

标签: java x3d

编译某些代码以显示X3D文件时出错。运行代码时出现的错误是:

  

java.lang.ExceptionInInitializerError由以下引起:java.lang.RuntimeException:无法编译的源代码 - 在xj3dtest.Xj3DTest中不存在包org.web3d.x3d.sai。(Xj3DTest.java:7)线程中的异常&#34 ;主" Java结果:1

我的java代码是:

package xj3dtest;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
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;

public class Xj3DTest extends JFrame {

    public Xj3DTest(String title) {

        super(title);

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        X3DComponent x3dComponent = BrowserFactory.createX3DComponent(null);

        Browser browser = x3dComponent.getBrowser();

        Component browserComponent = (Component)  x3dComponent.getImplementation();

        Container cp = getContentPane();
        cp.setLayout(new BorderLayout());
        cp.add(browserComponent, BorderLayout.CENTER);

        X3DScene scene = browser.createX3DFromURL(new String[]   {"test.x3dv"});

        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);
    }
}

在test.x3dv文件中我有:

#X3D V3.0 utf8

PROFILE Interactive

DEF TS TimeSensor {
  cycleInterval 3
  loop TRUE
}

DEF TG Transform {
  rotation 0 1 0 0
  children Shape {
    geometry Box {}
    appearance Appearance {
      material DEF MAT Material {
        diffuseColor 1 0 0
      }
    }
  }
}

DEF OI OrientationInterpolator {
  key [ 0 0.5 1 ]
  keyValue [
     0 1 0 0
     0 1 0 3.14
     0 1 0 6.28
  ]
}

ROUTE TS.fraction_changed TO OI.set_fraction
ROUTE OI.value_changed TO TG.rotation

我在第7,8,9和10行都有错误,都说他们各自的包裹都不存在。我创建了一个带有jar的Xj3D库,并且我将以下命令行放入项目属性的VM选项中:-Xmx450M -Djava.library.path =' F:\ Uni \ Uni工作\ Year Three \ xj3d-code-12559-trunk \ bin'就像我已经获得了Xj3D代码一样。

0 个答案:

没有答案