Java3D Program Will Not Run

I’m trying to run the “BugRunner” Java3D program from the Killer Game Programming in Java book by O’Reilly (yes, I bought the book) and using

java BugRunner

does NOT work from a .bat file. I am wondering if anyone can tell me why/what to do to get it working. I assume this is a fairly easy fix. This is the first time I’ve ever used Java3D. There are errors and a paragraph of text in Command Prompt, but this only occurs when I run it like this. I don’t have this issue when running it in an IDE like BlueJ.

2 Likes

I do not have the book here for reference and I did not use Java3D before, but from what I understand you have a bat-file and in that file you try to run the “java BugRunner” command? When you run the command in the IDE directly it works, correct?

I am really not knowledgeable on programming on Windows, but my guess would be that when you execute the bat-file that it does not have the path to java and the file with the BugRunner code. You know how Windows (and Linux for that matter) keep a variable where to search for the binaries of the commands you want to run. Like when you run java in the Powershell it will search the path to see where the binary is and my guess here would be that it maybe either does not find the java binary or the code file you want to run.

But still, this is a wild guess and I have no experience with Windows in this regard. I can also not try myself anytime soon since I will be busy over Christmas, sorry.

yes

java FileNameHere

would be the same/equivalent in Terminal on Linux for running a Java .class file/Java program

@wendell
maybe?

Yes it would. But the small difference here is that is should not be the file name but the class name.

So it should be java <classname>

I grew up on that book! I can still see the cover in my head.

I ended up giving it to someone who wanted to learn, but I think I still have the old code somewhere…

could you post the error?

Is java installed and in home path?

I think @H-i-v-e is correct - maybe you haven’t compiled the code? javac <filename>.java compiles it and creates the .class file(s) that you need to point the java command at.

Please post the error - otherwise we’re just guessing…

Image

It’s installed to the default location, nothing fancy, or anything specific in particular

It’s not finding the J3DTimer class, which means it doesn’t see the Java3D library/files in your projects classpath.

You can do this a few ways:

  • You can add those files via the -cp parameter and give it the folder where the .jar files are, e.g, java -cp <jar_folder> <class>.
  • You can also set the “classpath” variable in your bat script to that folder
  • You can add it to window’s global classpath
2 Likes