0

I have an error when compiling some code to display an X3D file. The error that I have when I run the code is:

java.lang.ExceptionInInitializerError Caused by: java.lang.RuntimeException: Uncompilable source code - package org.web3d.x3d.sai does not exist at xj3dtest.Xj3DTest.(Xj3DTest.java:7) Exception in thread "main" Java Result: 1

The java code that I have 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 in the test.x3dv file I have:

#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

I have errors on lines 7, 8, 9 and 10 all saying that their respective packages don't exist. I have created an Xj3D library with the jars in and I've put the following command line into the VM options in the project properties: -Xmx450M -Djava.library.path='F:\Uni\Uni work\Year Three\xj3d-code-12559-trunk\bin' as that's where I've got the Xj3D code in.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
smitthy
  • 307
  • 4
  • 18
  • Using Netbeans? This is a [bug](https://netbeans.org/bugzilla/show_bug.cgi?id=199293) – OneCricketeer Feb 13 '16 at 17:56
  • Possible duplicate of ["Uncompilable source code" RuntimeException in netbeans](http://stackoverflow.com/questions/4386076/uncompilable-source-code-runtimeexception-in-netbeans) – OneCricketeer Feb 13 '16 at 17:57
  • I am using NetBeans for my project and I was unaware of that question already being asked. – smitthy Feb 14 '16 at 10:19

0 Answers0