Results 1 to 4 of 4

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: Native library gtkpeer not found

  1. #1
    Green Apple
    Join Date
    May 2010
    Location
    Under Your Bed, Ready to eat you
    Posts
    53
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Question Native library gtkpeer not found
    I have jamvm and jikes for the iPhone. This is my code:

    Code:
    import java.awt.Button;
    import java.awt.Frame;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.awt.event.WindowEvent;
    import java.awt.event.WindowListener;
    public class PracAWT{
        static WindowListener w = new WindowListener(){
        public void windowDeactivated(WindowEvent we){
    	 
        }
        public void windowActivated(WindowEvent we){
    	 
        }
        public void windowDeiconified(WindowEvent we){
    	 
        }
        public void windowIconified(WindowEvent we){
    	 
        }
        public void windowClosed(WindowEvent we){
    	 
        }
        public void windowClosing(WindowEvent we){
    	 f.setVisible(false);
             f.dispose();
             System.exit(0);
        }
        public void windowOpened(WindowEvent we){
    	 
        }
        };
        static int i = 0;
        static Button b = new Button("Click Me!");
        static Frame f = new Frame("Test");
        public static void main(String [] args){
            ActionListener l = new ActionListener(){
                public void actionPerformed(ActionEvent e){
                    i++;
                    if (i == 1){
                        b.setLabel("Clicked 1 time.");
                    } else {
                        b.setLabel("Clicked "+i+" times.");
                    }
                }
            };
            f.setVisible(true);
            b.addActionListener(l);
            f.add(b);
            f.setSize(300, 300);
            f.addWindowListener(w);
        }
    }
    Copy this code to your Computer, compile it, then run it. It should work!
    When I try to compile it (on my iPhone), it compiles perfectly well. But when I try to run it, this happens:

    This is it in text:
    java.awt.AWTError: Cannot load AWT toolkit: gnu.java.awt.peer.gtk.GtkToolkit
    at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:60 7)
    at java.awt.GraphicsEnvironment.getLocalGraphicsEnvir onment(GraphicsEnvironment.java:103)
    at java.awt.Window.<init>(Window.java:133)
    at java.awt.Frame.<init>(FRAME>.java:246)
    at PracAWT.<clinit>(PracAWT.java:35)
    Caused by java.lang.UnsatisfiedLinkError: Native library `gtkpeer' not found (as file `libgtkpeer') in gnu.classpath.boot.library.path and java.library.path
    at java.lang.Runtine.loadLibrary(Runtime.java:763);
    at java.lang.System.loadLibrary(System.java:662)
    at gnu.java.awt.peer.gtk.GtkToolkit.<clinit>(GtkToolk it.java:173)
    at java.lang.VMClass.forName(Native Method)
    at java.lang.Class.forName(Class.java:233)
    at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:58 3)
    ...4 more

    I thought that it might be because I'm using AWT things, and not swing things, so I changed my code so it said this:
    Code:
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.awt.event.WindowEvent;
    import java.awt.event.WindowListener;
    public class PracSwing{
        static WindowListener w = new WindowListener(){
        public void windowDeactivated(WindowEvent we){
    
        }
        public void windowActivated(WindowEvent we){
    
        }
        public void windowDeiconified(WindowEvent we){
    
        }
        public void windowIconified(WindowEvent we){
    
        }
        public void windowClosed(WindowEvent we){
    
        }
        public void windowClosing(WindowEvent we){
    	 f.setVisible(false);
             f.dispose();
             System.exit(0);
        }
        public void windowOpened(WindowEvent we){
    
        }
        };
        static int i = 0;
        static JButton b = new JButton("Click Me!");
        static JFrame f = new JFrame("Test");
        public static void main(String [] args){
            ActionListener l = new ActionListener(){
                public void actionPerformed(ActionEvent e){
                    i++;
                    if (i == 1){
                        b.setText("Clicked 1 time.");
                    } else {
                        b.setText("Clicked "+i+" times.");
                    }
                }
            };
            f.setVisible(true);
            b.addActionListener(l);
            f.add(b);
            f.setSize(300, 300);
            f.addWindowListener(w);
        }
    }
    I got the exact same error, probably because the swing components extend awt components (I mean javax.swing.JComponent extends java.awt.Component).

    I know I don't have any gtkpeer library on my iPhone because I did a find in the / directory:


    So: Can anyone tell me what I can do to fix this?

  2. #2
    I am having the same problem. You ever get it figured out?

  3. #3
    Green Apple
    Join Date
    May 2010
    Location
    Under Your Bed, Ready to eat you
    Posts
    53
    Thanks
    6
    Thanked 2 Times in 2 Posts

    I have found out. AWT is a little hard to do on the iPhone, so Saurik invented JocStrap. These are java wrappers for the Objective-C GUI elements, such as UIView or UIApplication. You could look inside jocstrap.jar for possible uses.
    Don't rewrite your permission groups, that involves reinventing the wheel!

  4. The Following User Says Thank You to thebombzen For This Useful Post:

    yo1dog (2010-09-13)

  5. #4
    Thanks! I appreciate it

    -------------------------------

    I am trying to compile the HelloJava example from JocStrap on my pc. I got the JocStrap SVN from menes - Revision 3341: /trunk/jocstrap, but the obc package is empty. I have been looking around but I can't find anything. What am I missing?

    Also, I downloaded and installed these packages from http://apt.saurik.com/cydia-3.7/debs/:
    apr_1.3.3-4_iphoneos-arm.deb
    libffi_130618-3_iphoneos-arm.deb
    jikes_1.22-3_iphoneos-arm.deb
    jocstrap_1.0.2549-8_iphoneos-arm.deb

    I originally tried to compile the HelloJava example from the JocStrap svn but after looking online it seems that this is not possible.

    -------------------------------

    Jumped the gun on that one. I found jacstrap.jar at: /usr/share/java/jocstrap.jar. I compiled the HelloJava example and tried to run it on my iPhone (3Gs 4.0.1). I got a large page of errors. The top-most one I can see says:
    Caused by: java.lang.NoClassDefFoundError: obc/UIApplication at java.lang.VMClassLoader.defineClass(Native Method)
    Is it not using the jocstrap library? Is there a way to test this?

    Thanks,
    - Mike
    Last edited by yo1dog; 2010-09-14 at 12:35 AM. Reason: Automerged Doublepost

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •