A guide to using the JOGL (Java OpenGL) bindings with JetBrains IDEs. This guide uses IntelliJ IDEA Ultimate and JOGL 2.6.0, but the same steps will work in the Community edition. I may use Windows specific terms in this guide, for instance file paths that start with the C: drive, however all of these instructions will work on any operating system (just make sure to adapt these to fit your operating systems requirements).
There are 3 main ways to install and use the JOGL bindings in IntelliJ, these are:
Download the jogamp-fat.jar file from jogamp.org. This file contains all the JOGL libraries and natives.
Create a folder to store the JOGL library. I prefer to keep all of my JAR libraries in one place, so I created a C:/Users/MyUserName/Libs/jogl folder to store the jogamp-fat.jar file, but you can create this wherever you like. Once you've created this folder, move the jogamp-fat.jar file into it.
Now launch IntelliJ and either create a new project or open your existing JOGL project. Open File > Project Structure.
Click the Modules tab from the menu in the newly opened window.
Click the + button in the tab, then select Library then select Java.
Navigate to the folder that jogamp-fat.jar is stored in and press Select Folder.
Press Okay to confirm the library creation.
Make sure to check the library to enable it in your project, then hit apply.
Now JOGL is successfully installed into your project. Make sure to read the Installing JOGL Sources section before you get started with development.
To install with Maven or Gradle using their build files, use the information from jogamp wiki.
Launch IntelliJ and either create a new project or open your existing JOGL project. Open File > Project Structure.
Click the Modules tab from the menu in the newly opened window.
Click the + button in the tab, then select Library then select From Maven....
Type jogl-all into the input field, and select the desired version from the search results. Then press okay.
Make sure to check the library to enable it in your project, then hit apply.
Now JOGL is successfully installed into your project. Make sure to read the Installing JOGL Sources section before you get started with development.
Installing the JOGL sources is something you will want to do, or you will be missing useful information like Javadoc on hover and function parameter names etc...
Installing JOGL sources will fix this problem.
To install the JOGL sources, follow the guide relevant to your JOGL install method:
On Maven Central, navigate to the version of JOGL that you are using.
In the files row of the table, click View All.
Download the jogl-all-x.x.x-sources.jar file.
Store the sources file wherever you would like.
Declare a JOGL variable (for example GL3 gl;) in the main function;
import com.jogamp.opengl.GL3;
public class Demo extends GLEventListener { // can ctrl + click on GLEventListener
public static void main() {
GL3 gl; // can ctrl + click on GL3
}
}Either Ctrl + Click on the type or press Alt + F4 whilst your cursor is within the type definition. This opens the decompiled bytecode, there will be a blue ribbon at the top of the file. Press Choose Sources....
Navigate to your jogl-all-x.x.x-sources.jar file and select it.
You have now successfully loaded the JOGL sources.
Make sure to read the Running a Project section before developing your project.
Declare a JOGL variable (for example GL3 gl;) in the main function;
import com.jogamp.opengl.GL3;
public class Demo extends GLEventListener { // can ctrl + click on GLEventListener
public static void main() {
GL3 gl; // can ctrl + click on GL3
}
}Either Ctrl + Click on the type or press Alt + F4 whilst your cursor is within the type definition. This opens the decompiled bytecode, there will be a blue ribbon at the top of the file. Press Download....
Maven or Gradle will then download and install the sources for you. If this fails, following the JAR tutorial will work.
Make sure to read the Running a Project section before developing your project.
The best way to run a JOGL project in Jetbrains is to use a Run Configuration. You can generate one automatically by clicking on the green triangle that appears in the gutter of the editor on the same line as your main function or class definition.
This will create a default run configuration with your main classes name which will be accessible from the configurations menu in the top right of the IntelliJ interface.
When you run this configuration, however, it will likely fail to work. This can be easily resolved by adding some vm arguments to the configuration. To do this, select Edit Configurations... from the configurations menu.
Select Modify options and then select Add VM options.
This will add a new input field to the UI. Paste the following exports into this input field and hit apply.
--add-exports java.base/java.lang=ALL-UNNAMED
--add-exports java.desktop/sun.java2d=ALL-UNNAMED
--add-exports java.desktop/sun.awt=ALL-UNNAMEDThe project can now be successfully run by clicking the green triangle in the top right hand corner.























