title: How to use createX3DFromStream in Java code
body: <p>I'm making a Java class named <code>Xj3DTester</code> which displays <code>X3D</code> and <code>X3DV</code> files and when I run it, I get the following runtime error message.</p>
  
  <pre><code>run:
  Mar 23, 2016 12:47:39 PM java.util.prefs.WindowsPreferences &lt;init&gt;
  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 23, 2016 12:47:42 PM org.odejava.Odejava &lt;clinit&gt;
  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.&lt;clinit&gt;(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.&lt;clinit&gt;(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.&lt;init&gt;(BrowserJPanel.java:256)
      at org.xj3d.ui.awt.browser.ogl.X3DBrowserJPanel.&lt;init&gt;(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.&lt;init&gt;(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.x3d.sai.InvalidURLException: Unable to load any URLS
      at org.web3d.vrml.scripting.external.sai.SAIBrowser.createX3DFromURL(SAIBrowser.java:846)
      at xj3dtest.Xj3DTest.&lt;init&gt;(Xj3DTest.java:50)
      at xj3dtest.Xj3DTest.main(Xj3DTest.java:56)
  </code></pre>
  
  <p>And my Java code is as follows.</p>
  
  <pre><code>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_cirlce_1.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);
      }
  }
  </code></pre>
  
  <p>From what I can see, the error is being caused by the <code>X3DScene scene = browser.createX3DFromURL(new String[]   {"hafodty_cirlce_1.x3dv"});</code> line and that I need to use the <code>createX3DFromStream</code> method instead of the <code>createX3DFromURL</code> method but I don't understand how it works and how to swap them round. I'm using Netbeans 8.1 and I have the X3D and X3DV files saved in the project. </p>
  
  <p>I'm aware that it could seem like I'm asking for help for the <code>Native code library</code> and I know how to fix that. I'm asking for help for the section that starts: <code>Exception in thread...</code></p>