DEV Community

Shawon Saha
Shawon Saha

Posted on

Run Java OpenGL (JOGL) on Linux

At first, make sure you have java installed on your system. To check that open Terminal (ctrl + alt + t) and run java -version

OpenJDK Linux

If you don't see any version then you have to install OpenJDK on your system. To do that run these two commands

sudo apt-get install openjdk-11-jre
sudo apt-get install openjdk-11-jdk

and check your java -version again.

Once you successfully install java on your system then you have to install JOGL. To do that run this command on terminal.

sudo apt-get install libjogl2-java

After installing JOGL install eclipse

Now Open Eclipse and Create a Java project and give your project a name.

Create a Java Project
You can also find it under File > New > Java Project

After giving a nice name in your project Click Next
Project Name

From the Libraries select Classpath and click Add External JARs Add External JARs

Navigate to /usr/share/java/ and choose these two files jogl2.jar and gluegen2-rt.jar.If you import correctly then You should see those file's paths under Classpath. Now click Finish (You can skip creating Module).
image

Now expand your project from the sidebar and right-click on src then Create a new class

image

If everything is done correctly a Canvas window will pop up after running your JOGL code!

image

Top comments (1)

Collapse
 
philopaterwaheed profile image
philo san

hey so it's a good tutorial but very specific to eclipse I've searched a lot on how to compile using the java compiler and link jogl but didn't find any