简体   繁体   English

在Netbeans中编写代码时Java导入错误

[英]Java import error when writing code in Netbeans

I'm writing some code and I'm getting errors on four different lines saying that packages don't exist. 我正在编写一些代码,但在四行不同的地方出现错误,说软件包不存在。 The errors are on lines 7 to 10, which say package org.web3d.x3d.sai does not exist . 错误出现在第7至10行,表示package org.web3d.x3d.sai does not exist The code that I have for this project is: 我为该项目编写的代码是:

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

And the code for the test.x3dv is: 而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

The reason why I'm making this little project is because I need to display .x3d files through a Java project. 之所以要创建这个小项目,是因为我需要通过Java项目显示.x3d文件。 I'm put -Xmx450M -Djava.library.path='F:\\Uni\\Uni work\\Year Three\\xj3d-code-12559-trunk\\bin' in the project properties VM option and have put all the x3d jars in a library called Xj3D . 我将-Xmx450M -Djava.library.path='F:\\Uni\\Uni work\\Year Three\\xj3d-code-12559-trunk\\bin'放在项目属性VM选项中,并将所有x3d jars放在一个名为Xj3D库。

When I've written this code. 当我编写这段代码时。 I have the errors on lines 7 to 10 and I don't know why. 我在第7到10行有错误,我不知道为什么。

EDIT 编辑

I've looked through all the Xj3D code trunk file that I have that has got the .jars in but I don't think it has the org.web3d.x3d.sai jar in. 我已经通过,我已经得到了所有的Xj3D代码主干文件中查找.jars中,但我不认为它具有org.web3d.x3d.sai jar英寸

EDIT 2 编辑2

I've downloaded the org.web3d.x3d.sai and I've put it in the JARS lib folder that I've made in Netbeans. 我已经下载了org.web3d.x3d.sai ,并将其放在在Netbeans中创建的org.web3d.x3d.sai lib文件夹中。 But I'm still getting the errors. 但是我仍然遇到错误。

EDIT 3 编辑3

I've moved things round and I've only used that one jar. 我把东西搬了过去,只用了一个罐子。 I've unzipped the file and used the jar itself and the errors have gone. 我解压缩了文件并使用了jar本身,错误消失了。 However, a new problem has occurred while I run the piece of code and it's giving me a NotSupportedException. 但是,当我运行这段代码时出现了一个新问题,它给了我一个NotSupportedException。

Google-> org.web3d.x3d.sai-> 第一个链接 ->查找下载 ->将其放在netbeans / lib文件夹中-> Profit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM