Menu

java.lang.UnsatisfiedLinkError

Help
kapamarou
2010-11-13
2012-09-23
  • kapamarou

    kapamarou - 2010-11-13

    Hello chrriis , thanks for amazing components.
    My english is not so good , but you will understand what i write to this post.
    My environment is Netbeans 7.0 M2 .I have imported all jar files from your
    project to libraries folder of my project that i have named DemoFrame.

    My OS is ubuntu and when i run this , i get exception

    NativeSwing[1]: Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: 
    NativeSwing[1]:         no swt-win32-3650 in java.library.path
    NativeSwing[1]:         no swt-win32 in java.library.path
    NativeSwing[1]:         Can't load library: /tmp/swtlib-32/libswt-win32-3650.so
    NativeSwing[1]:         Can't load library: /tmp/swtlib-32/libswt-win32.so
    NativeSwing[1]: 
    NativeSwing[1]:         at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
    NativeSwing[1]:         at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
    NativeSwing[1]:         at org.eclipse.swt.internal.C.<clinit>(Unknown Source)
    NativeSwing[1]:         at org.eclipse.swt.widgets.Display.<clinit>(Unknown Source)
    NativeSwing[1]:         at java.lang.Class.forName0(Native Method)
    NativeSwing[1]:         at java.lang.Class.forName(Class.java:169)
    NativeSwing[1]:         at org.eclipse.swt.graphics.Device.<clinit>(Unknown Source)
    NativeSwing[1]:         at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$OutProcess.runNativeSide(SWTNativeInterface.java:1201)
    NativeSwing[1]:         at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.main_(SWTNativeInterface.java:1385)
    NativeSwing[1]:         at chrriis.dj.nativeswing.swtimpl.NativeInterface.main(NativeInterface.java:220)
    NativeSwing[2]: Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: 
    NativeSwing[2]:         no swt-win32-3650 in java.library.path
    NativeSwing[2]:         no swt-win32 in java.library.path
    NativeSwing[2]:         Can't load library: /tmp/swtlib-32/libswt-win32-3650.so
    NativeSwing[2]:         Can't load library: /tmp/swtlib-32/libswt-win32.so
    NativeSwing[2]: 
    NativeSwing[2]:         at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
    NativeSwing[2]:         at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
    NativeSwing[2]:         at org.eclipse.swt.internal.C.<clinit>(Unknown Source)
    NativeSwing[2]:         at org.eclipse.swt.widgets.Display.<clinit>(Unknown Source)
    NativeSwing[2]:         at java.lang.Class.forName0(Native Method)
    NativeSwing[2]:         at java.lang.Class.forName(Class.java:169)
    NativeSwing[2]:         at org.eclipse.swt.graphics.Device.<clinit>(Unknown Source)
    NativeSwing[2]:         at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$OutProcess.runNativeSide(SWTNativeInterface.java:1201)
    NativeSwing[2]:         at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.main_(SWTNativeInterface.java:1385)
    NativeSwing[2]:         at chrriis.dj.nativeswing.swtimpl.NativeInterface.main(NativeInterface.java:220)
    NativeSwing[3]: Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: 
    NativeSwing[3]:         no swt-win32-3650 in java.library.path
    NativeSwing[3]:         no swt-win32 in java.library.path
    NativeSwing[3]:         Can't load library: /tmp/swtlib-32/libswt-win32-3650.so
    NativeSwing[3]:         Can't load library: /tmp/swtlib-32/libswt-win32.so
    NativeSwing[3]: 
    NativeSwing[3]:         at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
    NativeSwing[3]:         at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
    NativeSwing[3]:         at org.eclipse.swt.internal.C.<clinit>(Unknown Source)
    NativeSwing[3]:         at org.eclipse.swt.widgets.Display.<clinit>(Unknown Source)
    NativeSwing[3]:         at java.lang.Class.forName0(Native Method)
    NativeSwing[3]:         at java.lang.Class.forName(Class.java:169)
    NativeSwing[3]:         at org.eclipse.swt.graphics.Device.<clinit>(Unknown Source)
    NativeSwing[3]:         at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$OutProcess.runNativeSide(SWTNativeInterface.java:1201)
    NativeSwing[3]:         at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.main_(SWTNativeInterface.java:1385)
    NativeSwing[3]:         at chrriis.dj.nativeswing.swtimpl.NativeInterface.main(NativeInterface.java:220)
    Exception in thread "main" java.lang.RuntimeException: java.net.SocketException: Connection reset
            at chrriis.dj.nativeswing.swtimpl.core.OutProcessSocketsMessagingInterface.openChannel(OutProcessSocketsMessagingInterface.java:67)
            at chrriis.dj.nativeswing.swtimpl.core.MessagingInterface.initialize(MessagingInterface.java:57)
            at chrriis.dj.nativeswing.swtimpl.core.OutProcessSocketsMessagingInterface.<init>(OutProcessSocketsMessagingInterface.java:32)
            at chrriis.dj.nativeswing.swtimpl.core.OutProcessSocketsMessagingInterface$SwingOutProcessSocketsMessagingInterface.<init>(OutProcessSocketsMessagingInterface.java:162)
            at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$OutProcess.createOutProcessMessagingInterface(SWTNativeInterface.java:1030)
            at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$OutProcess.createOutProcessCommunicationChannel(SWTNativeInterface.java:732)
            at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.open_(SWTNativeInterface.java:317)
            at chrriis.dj.nativeswing.swtimpl.NativeInterface.open(NativeInterface.java:100)
            at chrriis.dj.nativeswing.swtimpl.demo.DemoFrame.main(DemoFrame.java:48)
    Caused by: java.net.SocketException: Connection reset
            at java.net.SocketInputStream.read(SocketInputStream.java:168)
            at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
            at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
            at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
            at java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java:2266)
            at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2279)
            at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2750)
            at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:780)
            at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
            at chrriis.dj.nativeswing.swtimpl.core.OutProcessSocketsMessagingInterface.openChannel(OutProcessSocketsMessagingInterface.java:65)
            ... 8 more
    Java Result: 1
    

    I know that something is going on with my configuration but to me it's not
    clear .Below is the code from DemoFrame .

    package chrriis.dj.nativeswing.swtimpl.demo;
    
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.util.Arrays;
    
    import javax.swing.BorderFactory;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.SwingUtilities;
    
    import chrriis.common.UIUtils;
    import chrriis.dj.nativeswing.swtimpl.NativeInterface;
    import chrriis.dj.nativeswing.swtimpl.components.JWebBrowser;
    import chrriis.dj.nativeswing.swtimpl.components.WebBrowserFunction;
    
    /**
     * @author Christopher Deckers
     */
    public class DemoFrame extends JPanel {
    
        private static final String LS = System.getProperty("line.separator");
    
        public DemoFrame() {
            super(new BorderLayout());
            JPanel webBrowserPanel = new JPanel(new BorderLayout());
            webBrowserPanel.setBorder(BorderFactory.createTitledBorder("Native Web Browser component"));
            JWebBrowser webBrowser = new JWebBrowser();
            webBrowser.setBarsVisible(false);
            final JTextArea functionCallsTextArea = new JTextArea(7, 0);
            webBrowser.registerFunction(new WebBrowserFunction("invokeJava") {
    
                @Override
                public Object invoke(JWebBrowser webBrowser, Object... args) {
                    StringBuilder sb = new StringBuilder();
                    sb.append("-> " + getName() + "() called from Javascript with args:");
                    for (int i = 0; i < args.length; i++) {
                        Object arg = args[i];
                        if (arg == null) {
                            sb.append(LS).append("  null");
                        } else {
                            sb.append(LS).append("  ").append(arg instanceof Object[] ? Arrays.deepToString((Object[]) arg) : arg.toString()).append(" (").append(arg.getClass().getSimpleName()).append(")");
                        }
                    }
                    sb.append(LS).append("-> return Object[] result:").append(LS).append("  (short)3").append(LS).append("  true").append(LS).append("  null").append(LS).append("  new Object[] {\"A String\", false}").append(LS).append("  \"Hello World!\"").append(LS).append("  2.0f / 3.0f");
                    functionCallsTextArea.setText(sb.toString());
                    functionCallsTextArea.setCaretPosition(0);
                    return new Object[]{(short) 3, true, null, new Object[]{"A String", false}, "Hello World!", 2.0f / 3.0f};
                }
            });
            webBrowser.registerFunction(new WebBrowserFunction("invokeJavaWithError") {
    
                @Override
                public Object invoke(JWebBrowser webBrowser, Object... args) {
                    functionCallsTextArea.setText("-> " + getName() + "() called from Javascript." + LS + "-> Generating a Java runtime exception.");
                    functionCallsTextArea.setCaretPosition(0);
                    // This will generate an error
                    return 10 / 0;
                }
            });
            webBrowser.setHTMLContent(
                    "<html>" + LS
                    + "  <head>" + LS
                    + "    <script language=\"JavaScript\">" + LS
                    + "      function callJava() {" + LS
                    + "        var result = invokeJava(123, false, null, [1.2, ['hi', true]], 'swing');" + LS
                    + "        var s = 'Result from invokeJava():';" + LS
                    + "        for (var i = 0; i < result.length; i++) {" + LS
                    + "          s += '\\n    ' + result[i];" + LS
                    + "        }" + LS
                    + "        alert(s);" + LS
                    + "      }" + LS
                    + "      function callJavaWithError() {" + LS
                    + "        var s = 'Result from invokeJavaWithError():\\n    ';" + LS
                    + "        try {" + LS
                    + "          invokeJavaWithError();" + LS
                    + "          s += 'success';" + LS
                    + "        } catch (e) {" + LS
                    + "          s += 'Java error (' + e.message + ')';" + LS
                    + "        }" + LS
                    + "        alert(s);" + LS
                    + "      }" + LS
                    + "    </script>" + LS
                    + "  </head>" + LS
                    + "  <body>" + LS
                    + "    <p>" + LS
                    + "      Object[] invokeJava(123, false, null, [1.2, ['hi', true]], 'swing'):<br/><input id=button type=\"button\" value=\"call\" onclick=\"callJava();\">" + LS
                    + "    </p><p>" + LS
                    + "      Object invokeJavaWithError():<br/><input id=button type=\"button\" value=\"call\" onclick=\"callJavaWithError();\">" + LS
                    + "    </p>" + LS
                    + "  </body>" + LS
                    + "</html>");
            webBrowserPanel.add(webBrowser, BorderLayout.CENTER);
            webBrowserPanel.setPreferredSize(new Dimension(100, 200));
            add(webBrowserPanel, BorderLayout.NORTH);
            // Create an additional area to show the function calls.
            JPanel functionalCallsPanel = new JPanel(new BorderLayout());
            functionalCallsPanel.setBorder(BorderFactory.createTitledBorder("Java log for Javascript custom function calls"));
            functionCallsTextArea.setEditable(false);
            functionalCallsPanel.add(new JScrollPane(functionCallsTextArea));
            add(functionalCallsPanel, BorderLayout.CENTER);
        }
    
        /* Standard main method to try that test as a standalone application. */
    
        public static void main(String[] args) {
    
            UIUtils.setPreferredLookAndFeel();
            //NativeInterface.open();
            SwingUtilities.invokeLater(new Runnable() {
    
                public void run() {
                    JFrame frame = new JFrame("DJ Native Swing Test");
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.getContentPane().add(new DemoFrame(), BorderLayout.CENTER);
                    frame.setSize(800, 600);
                    frame.setLocationByPlatform(true);
                    frame.setVisible(true);
                }
            });
    
            //NativeInterface.runEventPump();
        }
    }
    

    What is wrong here with the code ?

    Thank you very much for your project

    Best regards George Tselios .

     
  • Christopher Deckers

    Hi George,

    On Ubuntu, you need to use the Linux version of SWT. Here, you are using SWT
    for Windows.

    To get the appropriate SWT for your platform, please go to:
    http://download.eclipse.org/eclipse/downloads/drops/S-3.7M3-201010281441/inde
    x.php#SWT

    Download, the right distribution, unzip "swt.jar" which you will use in your
    classpath.

    Hope this helps,
    -Christopher

     
  • kapamarou

    kapamarou - 2010-11-13

    Hello chriis again .Thanks for the fast replay .Yes it's all ok now except one
    thing more .I get this exception now

    java.lang.IllegalStateException: The SyntaxHighlighter distribution is missing from the classpath!
    at chrriis.dj.nativeswing.swtimpl.components.JSyntaxHighlighter.<init>(JSyntaxHighlighter.java:37)
    

    If you can send me an answear .

    Best regards
    George Tselios .

     
  • Christopher Deckers

    Hi George,

    Please add "SyntaxHighlighter_1.5.1.zip" to your classpath as if it were a JAR
    file. You need to add all the JARs and ZIPs from the "lib" folder depending on
    what feature you need.
    Note that running the demo this way will not allow you to see any source file
    when clicking on the "source" tab. This is because I have special scripts that
    copy source files when I prepare the distribution of the demo (but you have
    the sources anyway).

    Hope this helps,
    -Christopher

     
  • kapamarou

    kapamarou - 2010-11-13

    !!!!! Correct .Thanks again chris

     
  • memo

    memo - 2011-08-03

    hi chriis, i have same problem. i develop a desktop app on windows and when i
    run on mac i have exception ;

    Uncaught exception in main method: java.lang.UnsatisfiedLinkError: Could not
    load SWT library. Reasons:
    no swt-win32-3721 in java.library.path
    no swt-win32 in java.library.path
    Can't load library: /Users/dilekd/.swt/lib/macosx/x86/libswt-win32-3721.jnilib
    Can't load library: /Users/dilekd/.swt/lib/macosx/x86/libswt-win32.jnilib

    could you help me pleas?

     
  • _

    _ - 2011-08-03

    @amisorih I would hazard a guess at the fact you would need the mac SWT
    library when running on a mac machine rather than the windows one.

    Nick

     
  • memo

    memo - 2011-08-03

    how can i integrate mac SWT to IDE or jar file

     
  • Christopher Deckers

    Hi,

    SWT requires a different JAR for each platform. Have a look at the 3.7M5
    releases of SWT, which are currently in use in the latest DJ Native Swing
    distribution (note: there are more recent versions of SWT, official "3.7" is
    out):

    http://archive.eclipse.org/eclipse/downloads/drops/S-3.7M5-201101272034/index
    .php#SWT

    For Mac, you need the Cocoa version, either 32 bit or 64 bit. If you download
    the 32 bit version, you can use it on a 64 bit JVM on Mac by running the JVM
    with the "-d32" flag.

    Hope this helps,
    -Christopher

     
  • Vijay Rumao

    Vijay Rumao - 2011-08-14

    Hi Chriis,
    How are you ? I am trying to use the DJ Native Swing library which has really
    amazing capabilities Thanks. I am using eclipse on windows xp 32 bit. I am
    trying to run the demos I am able to run the simplewebbrowser demo but when I
    run the FullPageCaptureExample and try hitting the capture button I get the
    following exception This same exception also occurs when I try to print the
    contents of SimpleWebBrowser example to a page. Also when I run the online
    example for FullPageCaptureExample the application freezes.

    NativeSwing: Exception in thread "NativeSwing Component Image Data Transfer"
    java.lang.IllegalStateException: Not implemented
    NativeSwing: at chrriis.dj.nativeswing.swtimpl.core.SWTNativeComponent$CMN_get
    ComponentImage.sendImageData(SWTNativeComponent.java:1505)
    NativeSwing: at chrriis.dj.nativeswing.swtimpl.core.SWTNativeComponent$CMN_get
    ComponentImage.access$1(SWTNativeComponent.java:1440)
    NativeSwing: at chrriis.dj.nativeswing.swtimpl.core.SWTNativeComponent$CMN_get
    ComponentImage$3.run(SWTNativeComponent.java:1445)

    I highly appreciate your help. Thanks in advance
    Regards
    Vijay

     
  • Christopher Deckers

    Hi Vijay,

    Are you on a system with limited number of colors on screen? What kind of
    color model do you have?

    The issue is that you are hitting some code which I never thought I would need
    to implement. I could probably implement it but I want to better understand
    the conditions in which this happens.

    Cheers,
    -Christopher

     
  • Christopher Deckers

    Hi Vijay,

    I actually took a closer look and implemented the indexed color model.
    Component printing should work now using the latest 1.0.2 preview
    (DJNativeSwing-SWT-1-0-2-2011082).

    Please let me know if it works as expected if you get to test it where it used
    to fail (especially because I could not test my implementation).

    Cheers,
    -Christopher

     

Log in to post a comment.