problems with java3D lib configuration

I know this question is now a few years old, but the answers here were not enough for me to solve the problem. They only helped partially. http://www.filsa.net/2008/07/17/eclipse-java3d-and-javalibrarypath/ was also a bit helpful, but it was still not enough. Therefore I felt obliged to write a complete checklist to have Java3D work in Eclipse.

A few months ago, I already had the same problem and I somehow solved it without really understanding what I did. Today I wanted to set up my environment on a different computer and guess what, I had the same problem again. And I forgot what I had to do… This time however, I solved the problem more systematically and now I understand every step.

The Solution – every step in detail

1) If you are importing someone else’s project, make sure to have the correct JDK and JRE installed and selected in Eclipse. My Eclipse had selected the latest JRE 7. The only one I had installed. But the Project that I work on requires JDK 6 and JRE 6. I recommend the following structure on your file system if you need to have multiple java versions

  • somePath/Java/JDK/JDK6/
  • somePath/Java/JDK/JDK7/
  • somePath/Java/JRE/JRE6/
  • somePath/Java/JRE/JRE7/
  • somePath/Java/Java3D/

2) In Eclipse, you will have to do the following steps to select the correct JDK and JRE.

  • Project > Properties > Java Compiler, check “Enable project specific settings”, then select the correct Compiler compliance level for your project. In my case it’s 1.6 for the use with JDK6. (The naming was really confusing for me, at least the 6 was a hint.)
  • You also have to make sure that the correct JRE is used when you run the application. Therefore open Run>Run Configurations and select the tab JRE. If you use JDK 6, then you have to make sure that JRE 6 is used. You can add JREs if you click onto “Installed JREs” and then add the somePath/Java/JRE/JRE6/ directory.

3) Having your Java environment set up correctly, make sure that Java3D is installed on your machine. You can’t do anything wrong with this.

4) In your Java3D installation directory, locate the files

  • j3dcore-ogl.dll (for Windows; on Linux it’s j3dcore-ogl.so)
  • j3dcore.jar
  • j3dutils.jar
  • vecmath.jar

It doesn’t matter where these files are located if you setup your environment correctly, which I will explain. So if you want, you can copy these files into your project directory to have everything you need in one place.

5) Having located these files, make sure that

  • On your Operating System, the location of j3dcore-ogl.dll is added to the PATH variable. The .dll or .so file contains machine native code that Java3D uses. Your system needs to be aware of this code’s existence.
    Under Windows, to set the PATH variable, you open the System Settings in your Control Panel and select Advanced System Settings. On the bottom you will find the button “Environment Variables”. In the System Variables list you will find the variable “Path”. Make sure the directory of j3dcore-ogl is included in the list of paths.
  • Back in Eclipse, wherever the *.jar files currently are, make sure they are included in your Project>Properties>Java Build Path>Libraries. You can add them by either using Add JARs or Add External JARs, depending on whether you copied the three JARs to the project directory or not.

6) Now comes the part that saved my day today.

For each of the Java3D Libraries listed in the Java Build Path

  • j3dcore.jar
  • j3dutils.jar
  • vecmath.jar,

you need to specify Native Library Location. The Native library is the j3dcore-ogl.dll, so edit the native library location to point to the directory containing j3dcore-ogl.dll.

I believe, that these are all steps that must be done to setup Java3D in eclipse, because I set up everything on a fresh computer today. Now I hope that these instructions will save some other poor Java-beginners’, students’ or programmers’ day 🙂

Leave a Comment