• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java runtime error  RSS feed

 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I'm getting a runtime error when I'm trying to run some code. The aim of my code is to display some X3D and X3DV files in Java by using Xj3D. I've managed to get it to work when I'm using small files that are called 'test.x3d' and 'test.x3dv'. But when it comes to X3D files that I've been given, they have some URLs in that I'm thinking is causing the error as the error is



My Java code for this is



I do have the file 'hafodty_circle_1.x3dv' saved in the project, and I'm using Netbeans for this and I was wondering if anyone could help me?
 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know about the first error, but that second one is because the value you have supplied to the method createX3DFromURL is not a URL.

Since that file is on your machine I would guess you are supposed to get a stream for it and use the createX3DFromStream method instead.
 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The X3D file is on my machine and I got given it from a friend. I was wondering how I'd go about using the createX3DFromStream method?
 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By creating a FileInputStream using the path to the file.
 
Ron McLeod
Saloon Keeper
Posts: 1601
232
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error
   SEVERE: Native code library (32 and 64 bit library) failed to load: java.lang.UnsatisfiedLinkError: no odejava in java.library.path
is telling you that either the libodejava.dll library is missing, or is not in a directory where DLL files would normally be found.

Either ensure that the libodejava.dll is in the proper directory (such as C:\Windows\System32), or add a java.library.path property specifying where the DLL can be found (such as -Djava.library.path=c:\Users\me\myproject\jnilibs).
 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I need to do a FileInputStream class using the path to the file?

The 'SEVERE: Native code library (32 and 64 bit library) failed to load: java.lang.UnsatisfiedLinkError: no odejava in java.library.path' error is there when I run the java class when I have the 'test.x3d' and 'test.x3dv' files is; I'm wondering more about the bit that follows the 'Exception in thread...' line.
 
Campbell Ritchie
Marshal
Posts: 55793
164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will probably know already that unsatisfied link errors are caused by missing or faulty native libraries, in the case of Windows, .dll files. Have you considered reinstalling Java® in the same PATH as before?
 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have considered that and I've looked in the Netbeans Projects folder within my Documents to check to see if the native libraries were present which they are and as I've just installed Windows 10, there's a Windows 10 sub folder within the natives folder that's within the Netbeans Projects and it has the odejava64.dll in. And when I go into the Properties section of my project and to to Run, I have 'java -Djava.library.path="C:\Users\matt\Documents\NetBeansProjects\natives\Windows 10"' in the VM Options.

I've had a look on Google for a FileInputStream class, and I've found the following. And when I looked through it, I saw that it has a file input line where a file gets loaded. So should I keep that and use it and alter my code or vise versa?
 
Campbell Ritchie
Marshal
Posts: 55793
164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew Yeend wrote:. . . I've found the following. . . .
I am afraid I don't think that tutorial will help. There are lots of classes called XYZStream (not to be confused with this and its subinterfaces). If you go through the Java™ Tutorials, you find that classes called XYZStream are intended for reading binary files and classes called XYZReader (also XYZWriter) are designed to work with text files. So I start to worry when I see an XYZStream used to print the individual elements as chars.
You will find that binary files are probably best read as bytes or arrays of bytes. You will also find that you can get much better performance from some sorts of class by buffering them. You wil also find that the file input stream class has been part of the standard Java® IO API for as long as anybody can remember. So if the file you are trying to read is binary, then file input stream (or file output stream) will probably be the favoured way to handle those files. If the structure of your file is predictable you might be able to use a random access file object. I am by no means sure about that.

Whether that will get you out of the missing .dll error, I do not know.
 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The class that I have in the question does work with X3D files that don't have a URL in and it does display them, but the X3D files that I need to be displayed have URLs in which is why I'm getting the 'Exception in thread...' message so it isn't a matter of it working, it's just not displaying any X3D files that have URLs in.
 
Paul Clapham
Sheriff
Posts: 22526
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So when you try to work with a file containing a URL, that triggers some code which needs to access that DLL. And it isn't where it's supposed to be.

I would expect the DLL to be in one of the jars which you installed, rather than you having to manage the DLLs separately. Unless there were some installation instructions about how to deal with a separate bunch of DLLs? Or perhaps they have different jar files for Windows (with DLLs) versus Unix (with something else)?
 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The DLL error always occurs no matter which X3D file is loaded. When I load any X3D file with a URL, it triggers the 'Exception in thread "main"...' bit.

I'm using Windows and the DLLs got installed as I installed Netbeans and they're in a subfolder called 'natives' and within natives, they're in a subfolder called 'Windows 10'
 
Campbell Ritchie
Marshal
Posts: 55793
164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
…and I presume the requisite .dll is inside that directory?
 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The .dll is inside that directory, yes
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!