Setting up a JogAmp project in your favorite IDE

These instructions assume that you've created a project in your favorite IDE, and now you want your project to be able to use a JogAmp library like JOGL, JOCL, JOAL, or GlueGen. We use JOGL as an example below, but these instructions work equally well for any other JogAmp library.

= Download a JogAmp library =

If you haven't done so already, download and extract the JogAmp library you want to use. For example, to download and extract JOGL, see the instructions at Downloading and installing JOGL.

To use a JogAmp library you'll have to add its JAR files to the Java classpath and its native libraries to the Java library path. Each IDE has a slightly different way to do this, as we show below.

Please note that all JogAmp libraries depend on the GlueGen runtime libraries. These are included in every JogAmp library for convenience, but are only required once in the classpath and library path of your project.

= Eclipse IDE =

Create a user library
You can make your new Eclipse project depend directly on all the JARs and native libraries, but it's inconvenient to do that every time you create a new project. Creating a user library bundles all the files together so you can include them in one step.


 * Click "Window > Preferences", then select "Java > Build Path > User Libraries" on the left.
 * Click the "New..." button, type "JOGL" for the library name, and click "OK".
 * Click the "Add JARs..." button, navigate to the directory where you've stored the JARs, select them, then click "Open".
 * Expand the jar in the list, double-click "Native library location", type the directory where native library files are stored, and click "OK".
 * Click "OK" to exit Preferences dialog.

Add the user library to your project's dependencies

 * Right-click your project in the Package Explorer and clock "Properties".
 * Select "Java Build Path" and click the "Libraries" tab.
 * Click "Add Library...", select "User Library", click "Next", check "JOGL", and click "Finish".
 * Click "OK" to dismiss the Properties dialog.

That's it! You can now use the library in your project.

= IntelliJ IDEA =

Add a library dependency to your project

 * Click "File > Project Structure".
 * Select "Modules" on the left, then click the "Dependencies" tab on the right.
 * Click the "Add..." button, then click "Library...".IntelliJ_setup_01_add_library.png
 * Type "JOGL" as the library name.
 * Click "Attach JAR Directories...", navigate to the directory where you extracted the JARs and click "OK".
 * Click "OK" to dismiss the Configure Library dialog.IntelliJ_setup_02_configure_library.png
 * Click "OK" to dismiss the Project Structure dialog. The external libraries in your project should now look like this.IntelliJ_setup_03_external_library.png

Add the native libraries to the run configuration

 * Click "Run > Edit Configurations".
 * Type -Djava.library.path=your/path/to/native/library/files in the "VM Parameters" box.IntelliJ_setup_04_run_configuration.png
 * Click "OK" to dismiss the Run/Debug Configurations dialog.

That's it! You can now use the library in your project.

= NetBeans IDE =

Create a library and add it to your project

 * Right-click your project and click "Properties".
 * Select "Libraries" on the left and click "Add Library...".
 * Click the "Create" button, then type "JOGL" for the library name and click "OK".NetBeans_setup_01_create_library.png
 * Click "Add JAR/Folder...", then navigate to the directory you extracted the JAR files, select them and click "Add JAR/Folder".
 * Click "OK" to dismiss the Customize Library dialog.
 * Click "Add Library" to dismiss the Add Library dialog.NetBeans_setup_02_add_library.png
 * Click "OK" to dismiss the Project Properties dialog. The libraries in your project should look like this.NetBeans_setup_03_libraries_in_project.png

Add the native libraries to the run configuration

 * Click "Run > Set Project Configuration > Customize...". Select "Run" on the left if it isn't selected already.
 * Type -Djava.library.path=your/path/to/native/library/files in the "VM Options" box.NetBeans_setup_04_native_library_path.png
 * Click "OK" to dismiss the Project Properties dialog.

That's it! You can now use the library in your project.

= vi and other text editors =

Create your project with the editor of your choice

 * For example, to open vi, simply type vi and press.
 * Type all your code, then save it.

Compile and run your project from the command line

 * We assume your JOGL JAR files are in a directory called jar, and your JOGL native library files are in a directory called lib.
 * First compile your program. We assume all your code is in a single file called name/someone/MyProject.java.
 * Windows: Type javac -classpath "jar\gluegen-rt.jar;jar\nativewindow.all.jar;jar\jogl.all.jar;jar\newt.all.jar" name\someone\MyProject.java
 * Linux/MacOS X: Type javac -classpath "jar/gluegen-rt.jar:jar/nativewindow.all.jar:jar/jogl.all.jar:jar/newt.all.jar" name/someone/MyProject.java


 * Then run your project. We assume your main class is name.someone.MyProject</tt>.
 * Windows: Type java -classpath "jar\gluegen-rt.jar;jar\nativewindow.all.jar;jar\jogl.all.jar;jar\newt.all.jar;." -Djava.library.path=lib name.someone.MyProject</tt>
 * Linux/MacOS X: Type java -classpath "jar/gluegen-rt.jar:jar/nativewindow.all.jar:jar/jogl.all.jar:jar/newt.all.jar:." -Djava.library.path=lib name.someone.MyProject</tt>

That's it! You can now use the library in your project.