Introduction
Before getting into the programming side of Java3D, we need to download and install the required libraries. For this guide I will be demonstrating how to import the Java3D API into Eclipse and Netbeans.
Downloads
Downloading your IDE
You may already have an IDE installed on your computer, this is fine. Providing it is either Eclipse or Netbeans, if it isn’t you may need to find another tutorial or figure this part out for yourself. It isn’t possible for me to do this same example for every IDE out there as I would be here forever so, I picked two of the most popular free IDE’s.
Downloading Eclipse
https://eclipse.org/downloads/
In my example I will be using Eclipse Neon, as this is currently the most recently available version of the software as of January 2017.
. 
Locate the download button and download the latest version.
Installing Eclipse is fairly simple after you download the installer run it and you will get the required files to run Eclipse.

Your folder structure should look somewhat similar to this. To run eclipse click the Eclipse application which has the Eclipse logo next to it.
Downloading NetBeans
https://netbeans.org/downloads/
If you’re new to programming/Java you will only require the Java SE version of NetBeans, if you already have the knowledge surrounding the other versions of NetBeans you can download one of the extended versions.

Locate the download button and download the latest version.
Now you need to install NetBeans, simply run the file you just downloaded and follow the installation instructions.

Providing you selected to create a desktop shortcut during the installation you will get a similar looking icon. Click it to run NetBeans.
Downloading the Java3D Libraries
Download Java3D
https://java3d.java.net/binary-builds.html
These are the libraries which will need to be imported into your IDE to create the Java3D programs. The download link above will automatically start the download for the zipped folder.
Extracting the libraries
Extracting the libraries requires an unzipping tool, Windows comes with a zipping/unzipping tool already installed so there should be no problem. Locate the zipped folder which you have just downloaded.

It should look like the image above. Now, to extract the contents of this zipped folder you need to right click it and unzip/extract it. This part will be different for people, depending on what unzipping software they are using. I am using WinRAR so, I will demonstrate this using WinRAR.

Click the extract button as shown above, this will create a standard folder in the same location and with the same name. Now you need to locate that folder.

Open the folder and you will find a file structure as in the example below.

You can almost ignore all of these files, except the j3d-jre zipped folder, this is another zipped folder which you will need to extract. Do the same as we have done previously and extract/unzip that zipped folder.

Open that folder, open the lib folder and finally open the ext folder. You will then find a file structure as seen below.

We are now done for this stage, you will need these three jar files later so it is recommended that you create a folder to hold them on your desktop or just remember where they are located.
Setups
Setting up Eclipse with Java3D
If you are using NetBeans you can skip this section.
Run the Eclipse application and you will be promoted to select a workspace. I setup a new folder on my Desktop called Java 3D Examples, you can do the same but feel free to call the folder whatever you like.

Right click in the “Project Explorer” and click “New”, then “Project”.

You will then be promoted with the project creation wizard, simply select “Java Project” and then “Next”.

Enter a project name, this is your choice. Finally, select the correct JRE version. If you do not have the JRE installed you can download it from here: http://www.oracle.com/.

Now you should have a fresh new project located in your project explorer. Right click the project and select the properties button. A window should appear as shown below.

On the left side of the window, click on the “Java Build Path”. Then click on “Libraries” in the main body of the window. Your screen should look like mines does below.

Now click the “Add External JARs…” button on the right side of the window. This will open a new file explorer window, locate the three files which we found before after extracting the Java3D package.

Highlight all of the files by either shift-clicking on them all or dragging the cursor to select them all. Then click the “Open” button, in the bottom right of the window.
You will now have a window looking similar to mine below.

We’re almost done. Finally we need to link the source for each of the JAR files. Find you way back to the Java3D file which you extracted before. This time instead of opening the lib folder, you want to open the bin folder. You will find the file shown below.

Copy this file to a folder which you can easily access, make sure to call this new folder “bin3d”. Then go back into Eclipse.
You need to click the “Source” button in the window as shown below. Then click onto the “Link Source…” button on the right of the window.

A window will open as shown below, click the “Browse…” button and a new window will open showing your file system.

You now need to locate the “bin3d” folder which you recently created. Once you have found it, select it and press the “OK” button.

Once you have done that you can now press the “Finish” button in that current window.
You will now need to hit the “Apply” button in the bottom right of the screen.
Go back into the “Libraries” tab in the current window, then click the drop down arrow next to each of the .jar files that we previously imported.

Each one of these .jar files has a “Native library location”, this is current set to none. Click on the “Native library location” for the “j3dcore.jar”, then press the “Edit…” button over to the right of the screen. Refer to the below image.

You will be greeted by the below window, click on the “Workspace…” button.

You will then find the below window, this window shows all of your current Eclipse projects in the current workspace. Locate the current project that you are working in and expand it by clicking the little arrow. Locate the “bin3d” folder and select it. Then hit the “OK” button.

Click “OK” again on the screen as shown below, ensure that the “Location path” is similar to mine.

You will be taken back to the main properties window. It should now look similar to mine, as shown in the image below.

You will now need to do this for the other two .jar files. Repeat exactly what has been done above for the “j3dcore.jar” file.
You will now need to hit the “Apply” button in the bottom right of the screen.
You can now press the “OK” button to close the properties window.
We now need to create a class and ensure that the files were imported correctly. Open your current project and right click on the “src” package folder. Click on “New” and then click on “Class”.

Make sure to name the class “HelloWorld” (class names cannot have spaces). Then press Finish.

Open up the new empty class file. We can now test whether or not you imported the files correctly. Copy the code below.

Hit the run button in the top toolbar in Eclipse, the button looks like the button shown below.
If the code compiled correctly, without any errors you will get a Java 3D application open which looks like the image below.

If everything worked correctly for you then congratulations! You can now close this tutorial and the remaining part of this tutorial is the same thing except in NetBeans. You should continue on to the next tutorial. For each project you make you will need to set up Eclipse in the same way.
Setting up NetBeans with Java 3D
Now you need to open NetBeans and create a new project. To create a new project right click in the project tab on the left of the screen, then press “New Project…”.

In the window which has just opened, press “Java” and then “Java Application”. You can then hit the “Next >” button.

Then, select a name for your project. I called mine “Hello 3D”, select a location and ensure you uncheck the “Create Main Class” box.

DOUBLE CHECK: Ensure you have the “Create Main Class” checkbox NOT checked.

You can now press the “Finish” button, your new project has been created and should be displayed like in the image below.

Right click the libraries folder and click “Add JAR/Folder…”. A window will then open showing your file explorer. Locate the three JAR files that we extracted before, like in the image below.

Highlight the three files by either shift-clicking on all of them or by dragging your mouse to select all of them. Then click the “Open” button.
Your libraries folder should look like mines, as shown in the image below.

We’re almost done. Finally we need to link the source for each of the JAR files. Find you way back to the Java3D file which you extracted before. This time instead of opening the lib folder, you want to open the bin folder. You will find the file shown below.

We need to put this into the root folder of your NetBeans project. Locate your NetBeans project. The file structure should look similar to the image below.

Drag the “j3dcore-ogl.dll” file into that folder. You can then go back into NetBeans.
Now we need to create a new class. In your project click the small “+” next to “Source Packages” and it should expand. Right click on “” and press “New” and then “Java Class…”.

Name the class “HelloWorld” (class names cannot have spaces) then press the “Finish” button.

Here is the code for a basic Java 3D program to test that all of the files have been imported correctly.

Now press the run button at the top of the screen to run the program.

If the program compiled successfully, the below image should be the result.

If everything worked correctly for you then congratulations! You are now done and can continue on with the programming tutorials. For each project you make you will need to set up NetBeans in the same way.

5 thoughts on “Getting Started: Java 3D API Installation”