Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting an exception when running some code  RSS feed

 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to run some code that imports test.x3dv in Java. The Java code that I have is:



And the test.x3dv is:



When I run the code, I get the following:



I believe it's to do with the line or the and trying to call a method on a null object and I don't know how to fix it. If anyone can help, it would be greatly appreciated.
 
Les Morgan
Rancher
Posts: 768
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have the x3d product?

If not you need to rewrite to support what you do have.
 
Paul Clapham
Sheriff
Posts: 22480
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I googled your exception description I found several other posts elsewhere which had exactly identical code. They can't all be crossposted by you so I conclude that you, like those other people, got that example from somewhere on the web. I think that the example should come with instructions on how to configure a browser in the browser factory, or something like that, but maybe it assumes you already did that based on earlier pages.

At any rate I'd suggest you go back to where you got the example and look around for instructions on how to set up your environment. If you're still stuck, then maybe you could post a link to whatever it is which contained that example?
 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By x3d product, I assume you mean the x3d file which I've placed in the Java project.

The reason why I posted it again here is in the hope someone might be able to help me understand how to overcome this problem with the browser factory line. As if someone explains how to get round it, I'll have a better understanding and won't have to carry on asking the question.
 
Fred Kleinschmidt
Bartender
Posts: 560
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the result of this call:


is 'null' a legal value to pas as the argument? Is x3dComponent null after the call? If so, you need to read the documentation of createX3DComponent() to see why it might return null.
 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've realised my mistake. And now I've changed it round. I now have:


In which I have a few errors. All the lines that have at the end don't have any errors, however the lines that have the errors on are the ones that have 'String.' and there's red lines underneath all the words that follow the 'String.' saying that it can't find the symbol
 
Paul Clapham
Sheriff
Posts: 22480
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, yes, that's because the String class doesn't have any of those members. Perhaps you need an actual string in those places (like "MEDIUM" for example)? Or perhaps there's some other class which does have those members and you should be using that other class instead of String? Without a link to the documentation I'm just speculating, though. Hopefully you do have a link to the documentation so you can look things up there.
 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I've put String."MEDIUM"; there's a red line under the whole line so and the link that I was following can be found here
 
Paul Clapham
Sheriff
Posts: 22480
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The documentation says it wants a String there. So use a String:



It could be said that the documentation was less than helpful in that it didn't show how to form a Java String literal, but perhaps it's just aimed too high.
 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've changed it round and now have the the following when I run the code:
 
Paul Clapham
Sheriff
Posts: 22480
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what did you specify for your renderer? So far your posted code hasn't mentioned that.
 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've just added the following line into the code for the renderer:
However, when I've run it with that line and put all the correct jars in the library, I get the following run time error:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!