xxjjnn
xxjjnn

Reputation: 15239

How to get JOGL on Ubuntu 11.10 to work

any help greatly appreciated.

Problem: Ubuntu 11.10 not playing nice with Java's JOGL

Summary of what has been established:

Details of what has been established:

JOGL was working fine with Ubuntu 11.04. Test file "T1.java" displayed a wireframe cube correctly. After updating Ubuntu to 11.10, when run in Eclipse the JOGL frame always froze not showing any JOGL goodness. I tried running a Java applet to check if java was broken, it worked fine. Java not broken. Checked my jogl user library in Eclipse, looks fine. Native library set correctly for all jars. I tried running the file in a terminal

    cd ~/workspace/projectname/src/packagename/
    javac T1.java 

and got 32 errors complaining that the packages could not be found. At this point I realised this is NOT an eclipse problem.

I changed environment variables at /etc/environment and /etc/profile, such that running:

echo $PATH

echo $CLASSPATH

and

echo $JAVA_HOME

all display ~/librambo/jar and ~/librambo/lib as they should (plus the JDK correctly appeared in PATH) (~/librambo is /home/rambo/librambo , rambo = username)

I tried putting the simple "T1.java" inside ~/librambo/jar and javac 'ing it from there, same problem. Then I tried:

javac -classpath jogl.all.jar T1.java

to determine if it would reduce the number of errors, and it claimed "error reading jogl.all.jar; error in opening zip file"

After extracting the jar file, it compiled but would not run. Running

ldd *.so

in the terminal, I saw it lacked "libjawt.so", as it complained "not found". After finding that library file and copying it into the ~/librambo/jar folder, it (ldd *.so) then complained about several other library packages, such as libmawt.so, libjvm.so etc. After they also joined the horrendous pool of files congregating in ~/librambo/jar, upon ldd'ing again it complained it could now not find libjawt.so - but I just 'fixed' that problem...

I also "gksu nautilus" 'd my way over to them jar files, and set their permissions to read/write for all users, and allowed them to be ran as executables.

I had been using sun-java-6, so in paranoia I decided to remove the other java SDKs in /usr/lib/jvm to prevent interference from there being too many jar files confusing it. Same problem. Installed JDK1.7.0, cleared out ~/librambo/jar leaving only the 4 jars (and T1.java), wouldn't compile - same 32 errors again. (I used "sudo update-alternatives --config java" to set the java version, I used java -version to check what version I'm using so thats not the problem =p)

THis time downloaded jogl-linux-amd64.7z fresh, within it opened java-jogl-src.zip and copied the contents to /~librambo/jar again to see if I could just get it to work in this folder, 100 errors because the directory structure didn't match.

I have trawled much internets looking for answers for days, and I think I may finally have found it:

https://launchpad.net/ubuntu/oneiric/+source/libjogl-java/1.1.1+dak1-10

it says in the change log "Update the patch to set java.library.path" which is in keeping with an error I encountered (at some point). Unfortunately, when I download libjogl-java_1.1.1+dak1.orig.tar.gz and opened it, I realised I have no idea what I'm supposed to be doing with the contents. Could anyone tell me what to do to 'install' them?

Alternatively, here is the appendix, which contains the file hierarchy, /etc/environment setup, the 32 errors output, and a list of references which I have checked already.

////////////////////////////////////////

APPENDIX

////////////////////////////////////////

FILE HIERARCHY

ENVIRONMENT VARIABLES

32 ERRORS

    rambo@rambo-ThinkPad-SL510:~/librambo/jar$ javac T1.java 
    T1.java:3: package javax.media.opengl does not exist
    import javax.media.opengl.*;
    ^
    T1.java:4: package javax.media.opengl.awt does not exist
    import javax.media.opengl.awt.GLCanvas;
                                 ^
    T1.java:5: package com.jogamp.opengl.util does not exist
    import com.jogamp.opengl.util.*;
    ^
    T1.java:6: package javax.media.opengl.glu does not exist
    import javax.media.opengl.glu.GLU;
                                 ^
    T1.java:7: package com.jogamp.opengl.util.gl2 does not exist
    import com.jogamp.opengl.util.gl2.GLUT;
                                     ^
    T1.java:9: cannot find symbol
    symbol: class GLEventListener
    public class T1 extends Frame implements GLEventListener, ActionListener {
                                             ^
    T1.java:17: cannot find symbol
    symbol  : class GLCanvas
    location: class T1
      private GLCanvas canvas;
              ^
    T1.java:75: cannot find symbol
    symbol  : class GLAutoDrawable
    location: class T1
      public void display(GLAutoDrawable drawable) {
                          ^
    T1.java:81: cannot find symbol
    symbol  : class GLAutoDrawable
    location: class T1
      public void dispose(GLAutoDrawable drawable) {
                          ^
    T1.java:85: cannot find symbol
    symbol  : class GLAutoDrawable
    location: class T1
      public void init (GLAutoDrawable drawable) {
                        ^
    T1.java:92: cannot find symbol
    symbol  : class GLAutoDrawable
    location: class T1
      public void reshape (GLAutoDrawable drawable, int x, int y, int width, int height) {
                           ^
    T1.java:115: cannot find symbol
    symbol  : class GLU
    location: class Scene
      private GLU glu = new GLU();
              ^
    T1.java:116: cannot find symbol
    symbol  : class GLUT
    location: class Scene
      private GLUT glut = new GLUT();
              ^
    T1.java:133: cannot find symbol
    symbol  : class GL2
    location: class Scene
      public void render(GL2 gl) {
                         ^
    T1.java:145: cannot find symbol
    symbol  : class GL2
    location: class Scene
      private void drawAxes(GL2 gl) {
                            ^
    T1.java:20: cannot find symbol
    symbol  : variable GLProfile
    location: class T1
        GLProfile.initSingleton(true);
        ^
    T1.java:29: cannot find symbol
    symbol  : class GLProfile
    location: class T1
        GLProfile glp = GLProfile.getDefault();
        ^
    T1.java:29: cannot find symbol
    symbol  : variable GLProfile
    location: class T1
        GLProfile glp = GLProfile.getDefault();
                        ^
    T1.java:30: cannot find symbol
    symbol  : class GLCapabilities
    location: class T1
        GLCapabilities caps = new GLCapabilities(glp);
        ^
    T1.java:30: cannot find symbol
    symbol  : class GLCapabilities
    location: class T1
        GLCapabilities caps = new GLCapabilities(glp);
                                  ^
    T1.java:31: cannot find symbol
    symbol  : class GLCanvas
    location: class T1
        canvas = new GLCanvas(caps);
                     ^
    T1.java:56: cannot find symbol
    symbol  : class FPSAnimator
    location: class T1
        FPSAnimator animator = new FPSAnimator(canvas, 60);
        ^
    T1.java:56: cannot find symbol
    symbol  : class FPSAnimator
    location: class T1
        FPSAnimator animator = new FPSAnimator(canvas, 60);
                                   ^
    T1.java:76: cannot find symbol
    symbol  : class GL2
    location: class T1
        GL2 gl = drawable.getGL().getGL2();
        ^
    T1.java:86: cannot find symbol
    symbol  : class GL2
    location: class T1
        GL2 gl = drawable.getGL().getGL2();
        ^
    T1.java:93: cannot find symbol
    symbol  : class GL2
    location: class T1
        GL2 gl = drawable.getGL().getGL2();
        ^
    T1.java:99: cannot find symbol
    symbol  : variable GL2
    location: class T1
        gl.glMatrixMode(GL2.GL_PROJECTION);
                        ^
    T1.java:108: cannot find symbol
    symbol  : variable GL2
    location: class T1
        gl.glMatrixMode(GL2.GL_MODELVIEW);
                        ^
    T1.java:115: cannot find symbol
    symbol  : class GLU
    location: class Scene
      private GLU glu = new GLU();
                            ^
    T1.java:116: cannot find symbol
    symbol  : class GLUT
    location: class Scene
      private GLUT glut = new GLUT();
                              ^
    T1.java:134: cannot find symbol
    symbol  : variable GL2
    location: class Scene
        gl.glClear(GL2.GL_COLOR_BUFFER_BIT);
                   ^
    T1.java:148: cannot find symbol
    symbol  : variable GL2
    location: class Scene
        gl.glBegin(GL2.GL_LINES);
                   ^
    32 errors
    

REFERENCES

(Truncated list)

////////////////////////////////////////

UPDATES

////////////////////////////////////////

DAY 5 of java jogl headache update

PROGRESS!! =D

Now only 20 errors related to... Android? =S

So I started a new folder /home/rambo/libme

I downloaded:

from:

http://jogamp.org/deployment/jogamp-current/archive/jogamp-linux-amd64/

This time, i unpacked the 7zip files and saw a src zip folder in each. I copied the contents of both into libme, there were no overwrites - they share a similar folder structure though.

Then I changed the environment variables to point at libme. Then I moved T1.java into libme. Javac of T1 within libme gave the following complaint:

    rambo@rambo-ThinkPad-SL510:~/libme$ javac T1.java 
    /home/rambo/libme/jogamp/common/os/android/PackageInfoUtil.java:30: package android.content does not exist
    import android.content.*;
    ^
    /home/rambo/libme/jogamp/common/os/android/PackageInfoUtil.java:31: package android.content.pm does not exist
    import android.content.pm.*;
    ^
    /home/rambo/libme/jogamp/common/os/android/PackageInfoUtil.java:32: package android.util does not exist
    import android.util.Log;
                       ^
    /home/rambo/libme/jogamp/common/os/android/PackageInfoUtil.java:37: cannot find symbol
    symbol  : class PackageInfo
    location: class jogamp.common.os.android.PackageInfoUtil
       public static final PackageInfo getPackageInfo(String packageName) {
                           ^
    /home/rambo/libme/jogamp/common/os/android/PackageInfoUtil.java:41: cannot find symbol
    symbol  : class Context
    location: class jogamp.common.os.android.PackageInfoUtil
       public static final PackageInfo getPackageInfo(Context ctx, String packageName) {
                                                      ^
    /home/rambo/libme/jogamp/common/os/android/PackageInfoUtil.java:41: cannot find symbol
    symbol  : class PackageInfo
    location: class jogamp.common.os.android.PackageInfoUtil
       public static final PackageInfo getPackageInfo(Context ctx, String packageName) {
                           ^
    /home/rambo/libme/jogamp/common/os/android/StaticContext.java:30: package android.content does not exist
    import android.content.*;
    ^
    /home/rambo/libme/jogamp/common/os/android/StaticContext.java:31: package android.util does not exist
    import android.util.Log;
                       ^
    /home/rambo/libme/jogamp/common/os/android/StaticContext.java:34: cannot find symbol
    symbol  : class Context
    location: class jogamp.common.os.android.StaticContext
       private static Context context = null;
                      ^
    /home/rambo/libme/jogamp/common/os/android/StaticContext.java:37: cannot find symbol
    symbol  : class Context
    location: class jogamp.common.os.android.StaticContext
       public static final synchronized void setContext(Context ctx) {
                                                        ^
    /home/rambo/libme/jogamp/common/os/android/StaticContext.java:41: cannot find symbol
    symbol  : class Context
    location: class jogamp.common.os.android.StaticContext
       public static final synchronized Context getContext() {
                                        ^
    /home/rambo/libme/jogamp/common/os/android/PackageInfoUtil.java:44: cannot find symbol
    symbol  : class PackageInfo
    location: class jogamp.common.os.android.PackageInfoUtil
                   final PackageInfo pi = ctx.getPackageManager().getPackageInfo(packageName, PackageManager.GET_META_DATA);
                         ^
    /home/rambo/libme/jogamp/common/os/android/PackageInfoUtil.java:44: cannot find symbol
    symbol  : variable PackageManager
    location: class jogamp.common.os.android.PackageInfoUtil
                   final PackageInfo pi = ctx.getPackageManager().getPackageInfo(packageName, PackageManager.GET_META_DATA);
                                                                                              ^
    /home/rambo/libme/jogamp/common/os/android/PackageInfoUtil.java:45: cannot find symbol
    symbol  : variable Log
    location: class jogamp.common.os.android.PackageInfoUtil
                   if(DEBUG) Log.d(MD.TAG, "getPackageInfo("+packageName+"): "+pi);
                             ^
    /home/rambo/libme/jogamp/common/os/android/PackageInfoUtil.java:47: cannot find symbol
    symbol  : variable Log
    location: class jogamp.common.os.android.PackageInfoUtil
               } catch (Exception e) { if(DEBUG) { Log.d(MD.TAG, "getPackageInfo("+packageName+")", e); } }
                                                   ^
    /home/rambo/libme/jogamp/common/os/android/PackageInfoUtil.java:49: cannot find symbol
    symbol  : variable Log
    location: class jogamp.common.os.android.PackageInfoUtil
           if(DEBUG) Log.d(MD.TAG, "getPackageInfo("+packageName+"): NULL");
                     ^
    /home/rambo/libme/jogamp/common/os/android/PackageInfoUtil.java:54: cannot find symbol
    symbol  : class PackageInfo
    location: class jogamp.common.os.android.PackageInfoUtil
           final PackageInfo pInfo = getPackageInfo(packageName);
                 ^
    /home/rambo/libme/jogamp/common/os/android/PackageInfoUtil.java:58: cannot find symbol
    symbol  : class PackageInfo
    location: class jogamp.common.os.android.PackageInfoUtil
           final PackageInfo pInfo = getPackageInfo(packageName);
                 ^
    /home/rambo/libme/jogamp/common/os/android/PackageInfoUtil.java:60: cannot find symbol
    symbol  : variable Log
    location: class jogamp.common.os.android.PackageInfoUtil
           if(DEBUG) Log.d(MD.TAG, "getPackageInfoVersionName("+packageName+"): "+s);
                     ^
    /home/rambo/libme/jogamp/common/os/android/StaticContext.java:38: cannot find symbol
    symbol  : variable Log
    location: class jogamp.common.os.android.StaticContext
           if(DEBUG) Log.d(MD.TAG, "setContext("+ctx+")");
                     ^
    Note: /home/rambo/libme/javax/media/opengl/awt/GLCanvas.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    20 errors

Deleting the android folder didn't help. (If i use just the jogl src and not the gluegen, it gives 100 errors. Adding the source from joal does nothing either)

openGL test

    rambo@rambo-ThinkPad-SL510:~$ /usr/lib/nux/unity_support_test -p
    OpenGL vendor string:   ATI Technologies Inc.
    OpenGL renderer string: ATI Mobility Radeon HD 4500 Series
    OpenGL version string:  3.3.11005 Compatibility Profile Context
    
    Not software rendered:    yes
    Not blacklisted:          yes
    GLX fbconfig:             yes
    GLX texture from pixmap:  yes
    GL npot or rect textures: yes
    GL vertex program:        yes
    GL fragment program:      yes
    GL vertex buffer object:  yes
    GL framebuffer object:    yes
    GL version is 1.4+:       yes
    
    Unity 3D supported:       yes

Upvotes: 3

Views: 7593

Answers (2)

samael
samael

Reputation: 2168

Wow, you could save yourself a world of pain by using maven to handle your projects dependencies. See here: How to make jogl work with intellij idea

Upvotes: 1

xxjjnn
xxjjnn

Reputation: 15239

I fixed it! =D

Are YOU suffering the same problem?

Symptoms

Cure

Hold onto your pantaloons, you're in for one wild night.

@_@ "A thousand libraries, of the JOGL empire, descend upon you. Our JUnit tests, will blot out the sun"

¬_¬ "Then we will code in the shade"

Enter the following into a Terminal

sudo apt-get install gcc libgl1-mesa-dev libglu1-mesa-dev xorg-dev libice-dev libsm-dev libx11-dev libxext-dev libxxf86vm-dev libxinerama-dev libxrandr-dev libxrender-dev
sudo add-apt-repository ppa:eclipse-team/debian-package
sudo apt-get update
sudo apt-get install ant

It is assumed you use "git", if not then get it (google search, install). This guide was written for Java 1.7 (UPDATE: and Java 1.6), you can check your java version by typing

java -version

into the terminal. To change your default java version, type

sudo update-alternatives --config java

into the terminal - it displays the java versions you have installed, to choose from. Handy guides:

Now its Jogl time. Make a folder to put the source code to jogl onto your computer 0_0. For no particular reason, I will name the folder "hera" and put it into my home directory.

cd ~
mkdir hera
cd hera/
git clone git://jogamp.org/srv/scm/gluegen.git gluegen
git clone git://jogamp.org/srv/scm/jogl.git jogl

then goto ~/hera/jogl/doc/HowToBuild.html and it will tell you the next steps, though read these "how to build notes":

how to build notes

These are guide notes to the guide notes for JOGL, which you just GIT cloned into your computer at ~/hera/jogl/doc/HowToBuild.html

Advanced Users: It is important to note that "source /etc/environment" in insufficient when changing the environment variables in this case; in simples that means you need to do the next command to change your PATH (and other variables), LOG OUT and then LOG IN again to your Ubuntu.

gksu gedit /etc/environment

That command opens up your environment variables. Time for exterminatus. Remove all traces of ANYTHING java-like, including paths to SDKs. CLASSPATH and JAVA_HOME need to be deleted (copy them somewhere else so you can put them back later). You should have something like:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:~/.rvm/bin

Notice the no java there. Save and close. Log out, log in. Then check it worked with:

echo $PATH

If you see any java goodness despite the log out -> in, then "gksu gedit /etc/profile" and see if you have any "export" statements lingering in there which refer to PATH or CLASSPATH or JAVA_HOME. If nothing there... check ".bashrc" in home?

Advanced Users: The next paragraph goes through the building of Jogl. The Java version you use to do the building of Jogl is significant; it is the Java version your code will have to be to use it. If you want to develop projects (which use Jogl) in Java 1.6 and Java 1.7, then you'll need separate folders with separate builds of Jogl - for example "~/hera/" built with Java 1.7, "~/zeus/" built with Java 1.6.

Assuming everything is okay and there are no java paths showing, continue with the HowToBuild.html. I didn't change the optional build properties. Do the "ant" build thing the guide refers to. If you do the JUnit testing, it takes about 30mins, and appears to freeze a few times and not use any CPU. This is ok, just leave it for a while.

If the test doesn't work, it could potentially be because your unfortunate timing meant you've pulled a broken build. You can wait and git pull (from hera), or SHA1 your way back a few PUSHes.

Finally

Assuming you're using eclipse. Delete your old jogl user library that you made (if you made one). I also recommend starting a fresh project. Follow the guide (e.g. https://sites.google.com/site/justinscsstuff/jogl-tutorial-1 or http://www.leolol.com/drupal/game-programming) as normal, the following jars can be found in ~/hera/jogl/build/jar/ (If you're using Java 1.6, you'll have to ratch in ~/hera/jogl/builf/jar/atomic)

  • jogl.all.jar
  • jogl-all-natives-amd64.jar
  • newt.event.jar

their Native Library Location is in "~/hera/jogl/build/lib" . Then "gluegen-rt.jar" is found in "~/hera/gluegen/build" , I set the library to be the same one as for the other 3 jars... I suspect the presence of "libgluegen-rt.so" might have been fouling things up, one doesn't seem to need it...

Now your program should run!

At this point, you can put the PATH, CLASSPATH and JAVA_HOME variables back into /etc/environment (which were removed for the ant thing).

Upvotes: 3

Related Questions