Thread: [Java-gnome-developer] Problems running programs
Brought to you by:
afcowie
From: Bruno D. <bdu...@be...> - 2005-03-08 13:08:21
|
Hi, I must be the dumbest man in the world but I cannot compile/run any Java-Gnome program, whether it's with Eclipse or not ! I'm running Debian/Sid with Sun's JDK 1.4 Jar's are in /usr/share/java : bdusauso@Tu-144:~/workspace/First$ ls /usr/share/java docbook-xsl-saxon651-1.66.1.jar gnome2.8-2.8.2.jar gtk2.4-2.4.6.jar docbook-xsl-saxon65-1.66.1.jar gnome2.8.jar gtk2.4.jar docbook-xsl-saxon651.jar gnomevfs2.7-2.7.4.jar gtkhtml2.4-2.4.3.jar docbook-xsl-saxon65.jar gnomevfs2.7.jar gtkhtml2.4.jar docbook-xsl-xalan25-1.66.1.jar gnomevte0.11-0.11.13.jar docbook-xsl-xalan25.jar gnomevte0.11.jar And the .so's are in /usr/lib/jni : bdusauso@Tu-144:~/workspace/First$ ls /usr/lib/jni libgnomejar2.8.so libgnomevtejava0.11.so libgnomejar2.8.so.2.8.2 libgnomevtejava0.11.so.0.11.13 libgnomejava2.8.so libgtkhtmljar2.4.so libgnomejava2.8.so.2.8.2 libgtkhtmljar2.4.so.2.4.3 libgnomevfsjar2.7.so libgtkhtmljava2.4.so libgnomevfsjar2.7.so.2.7.4 libgtkhtmljava2.4.so.2.4.3 libgnomevfsjava2.7.so libgtkjar2.4.so libgnomevfsjava2.7.so.2.7.4 libgtkjar2.4.so.2.4.6 libgnomevtejar0.11.so libgtkjava2.4.so libgnomevtejar0.11.so.0.11.13 libgtkjava2.4.so.2.4.6 The program is the first one from the tutorial, that is : My CLASSPATH is as follows : bdusauso@Tu-144:~/workspace/First$ echo $CLASSPATH /usr/lib/j2se/1.4/jre/lib/rt.jar:/usr/share/java:. bdusauso@Tu-144:~/workspace/First$ cat First.java import org.gnu.gnome.App; import org.gnu.gnome.Program; import org.gnu.gtk.Gtk; public class First { public static void main(String[] args) { // Initialization Program.initGnomeUI("First", "0.1", args); App app = new App("First", "First App"); app.show(); Gtk.main(); } } So, when trying "javac First.java", I run into troubles ;) : bdusauso@Tu-144:~/workspace/First$ javac First.java First.java:14: package org.gnu.gnome does not exist import org.gnu.gnome.App; ^ First.java:15: package org.gnu.gnome does not exist import org.gnu.gnome.Program; ^ First.java:16: package org.gnu.gtk does not exist import org.gnu.gtk.Gtk; ^ First.java:22: cannot resolve symbol symbol : variable Program location: class First Program.initGnomeUI("First", "0.1", args); ^ First.java:24: cannot resolve symbol symbol : class App location: class First App app = new App("First", "First App"); ^ First.java:24: cannot resolve symbol symbol : class App location: class First App app = new App("First", "First App"); ^ First.java:27: cannot resolve symbol symbol : variable Gtk location: class First Gtk.main(); ^ 7 errors It seems javac don't find the packages, but my parameters (CLASSPATH especially) are right, no ? Another problem is when running Eclipse. I've set it up like shown in http://java-gnome.sourceforge.net/cgi-bin/bin/view/Main/EclipseDevelopment But, when running, Eclipse tells me : Exception in thread "main" java.lang.UnsatisfiedLinkError: /usr/lib/jni/libgnomejava2.8.so.2.8.2: libgtkjava2.4.so: cannot open shared object file: No such file or directory at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1586) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1511) at java.lang.Runtime.loadLibrary0(Runtime.java:788) at java.lang.System.loadLibrary(System.java:834) at org.gnu.gnome.Program.<clinit>(Program.java:74) at First.main(First.java:22) I'm sure i'm doing all things the wrong way, but I don't know how to do it right :) Is there a good soul who can help me ? Regards. -- Bruno Dusausoy <bdu...@be...> aka Thx1138 |
From: Jeff M. <ku...@gm...> - 2005-03-08 13:15:42
|
On Tue, 08 Mar 2005 14:08:06 +0100, Bruno Dusausoy <bdu...@be...> wrote: > My CLASSPATH is as follows : > > bdusauso@Tu-144:~/workspace/First$ echo $CLASSPATH > /usr/lib/j2se/1.4/jre/lib/rt.jar:/usr/share/java:. > ... > It seems javac don't find the packages, but my parameters (CLASSPATH > especially) are right, no ? The problem here is that the Java-GNOME libraries are not in your classpath. You need to add the gtk and gnome jar files to your classpath in order to compile this example. > But, when running, Eclipse tells me : > > Exception in thread "main" > java.lang.UnsatisfiedLinkError: /usr/lib/jni/libgnomejava2.8.so.2.8.2: > libgtkjava2.4.so: cannot open shared object file: No such file or > directory > at java.lang.ClassLoader$NativeLibrary.load(Native Method) > at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1586) > at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1511) > at java.lang.Runtime.loadLibrary0(Runtime.java:788) > at java.lang.System.loadLibrary(System.java:834) > at org.gnu.gnome.Program.<clinit>(Program.java:74) > at First.main(First.java:22) > > I'm sure i'm doing all things the wrong way, but I don't know how to do > it right :) > Is there a good soul who can help me ? > There is a simple solution for this issue as well. The example cannot find the Java-GNOME shared objects to load them at runtime. You can resolve this by either adding the path to the shared objects to your LD_LIBRARY_PATH env variable or you can specify -Djava.library.path=/usr/lib/jni as a VM argument. This VM argument is set up in the run dialog of eclipse by selecting the Arguments tab. -- Jeffrey Morgan "The highest reward for a man's toil is not what he gets for it, but what he becomes by it" - Jon Ruskin |
From: Clint A. <ca...@au...> - 2005-03-08 14:08:14
|
Bruno Dusausoy said: > Hi, > > I must be the dumbest man in the world but I cannot compile/run any Java-Gnome program, whether it's with Eclipse or not ! I don't think so, just uninformed. ;-) [snip] > My CLASSPATH is as follows : > > bdusauso@Tu-144:~/workspace/First$ echo $CLASSPATH > /usr/lib/j2se/1.4/jre/lib/rt.jar:/usr/share/java:. Here is your first problem. When adding .jar files to your classpath, you must specify each file individually, like this: /usr/share/java/gtk2.4.jar:/usr/share/java/gnome.jar:...etc. Putting just /usr/share/java won't work. Fix this and you'll fix the majority of your problems. [snip] > Another problem is when running Eclipse. I've set it up like shown in > > http://java-gnome.sourceforge.net/cgi-bin/bin/view/Main/EclipseDevelopment > > But, when running, Eclipse tells me : > > Exception in thread "main" > java.lang.UnsatisfiedLinkError: /usr/lib/jni/libgnomejava2.8.so.2.8.2: libgtkjava2.4.so: cannot open shared object file: No such file or directory > at java.lang.ClassLoader$NativeLibrary.load(Native Method) > at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1586) > at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1511) > at java.lang.Runtime.loadLibrary0(Runtime.java:788) > at java.lang.System.loadLibrary(System.java:834) > at org.gnu.gnome.Program.<clinit>(Program.java:74) > at First.main(First.java:22) > > This one is more tricky to figure out, but easy to fix. In Eclipse, open up the Run... dialog and click on the Environment tab. Click the New button to add a new environment variable: Name: LD_LIBRARY_PATH Value: /usr/lib/jni That should do it. Write back if you have more problems. |