Difference between revisions of "Java Gui"
Aqisecoxefi (Talk | contribs) |
Searchworks (Talk | contribs) (remove spam) |
||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Java GUI Howto == | == Java GUI Howto == | ||
*note: I am a linux newbie. The following steps are how I enabled the Java GUI functionality and may not be the correct way for everybody. If you know that one of these steps are bad, please correct it. | *note: I am a linux newbie. The following steps are how I enabled the Java GUI functionality and may not be the correct way for everybody. If you know that one of these steps are bad, please correct it. | ||
Line 18: | Line 10: | ||
- If you try to run a java GUI app now, it will print the error | - If you try to run a java GUI app now, it will print the error | ||
− | + | <code> | |
java.awt.AWTError: Cannot load AWT toolkit: gnu.java.awt.peer.gtk.GtkToolkit | java.awt.AWTError: Cannot load AWT toolkit: gnu.java.awt.peer.gtk.GtkToolkit | ||
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:607) | at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:607) | ||
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:103) | at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:103) | ||
− | at java.awt.Window.& | + | at java.awt.Window.<init>(Window.java:133) |
− | at java.awt.Frame.& | + | at java.awt.Frame.<init>(Frame.java:246) |
− | at javax.swing.JFrame.& | + | at javax.swing.JFrame.<init>(JFrame.java:123) |
at HelloJavaWorld.main(HelloJavaWorld.java:8) | at HelloJavaWorld.main(HelloJavaWorld.java:8) | ||
Caused by: java.lang.UnsatisfiedLinkError: Native library `gtkpeer' not found (as file `libgtkpeer.so') in gnu.classpath.boot.library.path and java.library.path | Caused by: java.lang.UnsatisfiedLinkError: Native library `gtkpeer' not found (as file `libgtkpeer.so') in gnu.classpath.boot.library.path and java.library.path | ||
at java.lang.Runtime.loadLibrary(Runtime.java:763) | at java.lang.Runtime.loadLibrary(Runtime.java:763) | ||
at java.lang.System.loadLibrary(System.java:662) | at java.lang.System.loadLibrary(System.java:662) | ||
− | at gnu.java.awt.peer.gtk.GtkToolkit.& | + | at gnu.java.awt.peer.gtk.GtkToolkit.<clinit>(GtkToolkit.java:173) |
at java.lang.VMClass.forName(Native Method) | at java.lang.VMClass.forName(Native Method) | ||
at java.lang.Class.forName(Class.java:233) | at java.lang.Class.forName(Class.java:233) | ||
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:583) | at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:583) | ||
...5 more | ...5 more | ||
− | + | </code> | |
- you must add libgtkpeer.so and libjawt.so. Both are located in the directory | - you must add libgtkpeer.so and libjawt.so. Both are located in the directory | ||
'''(ROOT)/gumstix-oe/tmp/work/armv5te-angstrom-linux-gnueabi/classpath-0.96.1-r2/install/classpath-gtk/usr/lib/classpath''' | '''(ROOT)/gumstix-oe/tmp/work/armv5te-angstrom-linux-gnueabi/classpath-0.96.1-r2/install/classpath-gtk/usr/lib/classpath''' | ||
put it in /usr/lib/classpath directory on the gumstix. | put it in /usr/lib/classpath directory on the gumstix. | ||
− | ''scp libgtkpeer.so libjawt.so root@ | + | ''scp libgtkpeer.so libjawt.so root@<IP>:/usr/lib/classpath'' works, or any other method |
3) run ldconfig | 3) run ldconfig | ||
− | + | <code> | |
ldconfig | ldconfig | ||
− | + | </code> | |
4) point to display 0.0. You can do this by typing the line | 4) point to display 0.0. You can do this by typing the line | ||
− | + | <code> | |
export DISPLAY=:0.0 | export DISPLAY=:0.0 | ||
− | + | </code> | |
before executing java | before executing java | ||
Line 60: | Line 52: | ||
I enabled the GUI support by adding the two classpath lines to the INSTALL part of the image I use (gumstix-x11-32mb-image.bb), like so: | I enabled the GUI support by adding the two classpath lines to the INSTALL part of the image I use (gumstix-x11-32mb-image.bb), like so: | ||
− | IMAGE_INSTALL += | + | IMAGE_INSTALL += " \ |
# multiple lines removed to shorten this text... | # multiple lines removed to shorten this text... | ||
classpath \ | classpath \ | ||
classpath-awt \ | classpath-awt \ | ||
jamvm \ | jamvm \ | ||
− | + | " | |
Consider making a user.collection recipe of your changes to not get conflicts when the repository is updated. | Consider making a user.collection recipe of your changes to not get conflicts when the repository is updated. | ||
[[Category:How_to_-_JAVA]] | [[Category:How_to_-_JAVA]] |
Latest revision as of 15:32, 23 November 2010
Java GUI Howto
- note: I am a linux newbie. The following steps are how I enabled the Java GUI functionality and may not be the correct way for everybody. If you know that one of these steps are bad, please correct it.
1) Add jamvm to the gumstix-x11-image and compile/download to gumstix. - modify (ROOT)/gumstix-oe/com.gumstix.collection/packages/images/gumstix-x11-image.bb and add jamvm to the IMAGE_INSTALL list - follow the steps at this howto to compile and download image to gumstix
2) Add the GUI libs
- If you try to run a java GUI app now, it will print the error
java.awt.AWTError: Cannot load AWT toolkit: gnu.java.awt.peer.gtk.GtkToolkit at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:607) at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:103) at java.awt.Window.<init>(Window.java:133) at java.awt.Frame.<init>(Frame.java:246) at javax.swing.JFrame.<init>(JFrame.java:123) at HelloJavaWorld.main(HelloJavaWorld.java:8) Caused by: java.lang.UnsatisfiedLinkError: Native library `gtkpeer' not found (as file `libgtkpeer.so') in gnu.classpath.boot.library.path and java.library.path at java.lang.Runtime.loadLibrary(Runtime.java:763) at java.lang.System.loadLibrary(System.java:662) at gnu.java.awt.peer.gtk.GtkToolkit.<clinit>(GtkToolkit.java:173) at java.lang.VMClass.forName(Native Method) at java.lang.Class.forName(Class.java:233) at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:583) ...5 more
- you must add libgtkpeer.so and libjawt.so. Both are located in the directory (ROOT)/gumstix-oe/tmp/work/armv5te-angstrom-linux-gnueabi/classpath-0.96.1-r2/install/classpath-gtk/usr/lib/classpath put it in /usr/lib/classpath directory on the gumstix. scp libgtkpeer.so libjawt.so root@<IP>:/usr/lib/classpath works, or any other method
3) run ldconfig
ldconfig
4) point to display 0.0. You can do this by typing the line
export DISPLAY=:0.0
before executing java
Adding Classpath with GUI support to your image
I enabled the GUI support by adding the two classpath lines to the INSTALL part of the image I use (gumstix-x11-32mb-image.bb), like so:
IMAGE_INSTALL += " \ # multiple lines removed to shorten this text... classpath \ classpath-awt \ jamvm \ "
Consider making a user.collection recipe of your changes to not get conflicts when the repository is updated.