0

I am trying to use JWebBrowser in my project. Everything works fine in my computer. But when I try to use the executive jar on other computers, nothing happens when I double click. Below is the example code, works fine on my computer but not working on other computers. How can I solve this proble?

Is there a way to get error messages for the executive jars, like I got from the eclipse console ?

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.BorderFactory;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import chrriis.common.UIUtils;
import chrriis.dj.nativeswing.swtimpl.NativeInterface;
import chrriis.dj.nativeswing.swtimpl.components.JWebBrowser;

/**
 * @author Christopher Deckers
 */
public class Main extends JPanel {

  public Main() {
    super(new BorderLayout());
    JPanel webBrowserPanel = new JPanel(new BorderLayout());
    webBrowserPanel.setBorder(BorderFactory.createTitledBorder("Native Web Browser component"));
    final JWebBrowser webBrowser = new JWebBrowser();
    webBrowser.navigate("http://www.google.com");
    webBrowserPanel.add(webBrowser, BorderLayout.CENTER);
    add(webBrowserPanel, BorderLayout.CENTER);

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 4, 4));
    JCheckBox menuBarCheckBox = new JCheckBox("Menu Bar", webBrowser.isMenuBarVisible());
    menuBarCheckBox.addItemListener(new ItemListener() {
      public void itemStateChanged(ItemEvent e) {
        webBrowser.setMenuBarVisible(e.getStateChange() == ItemEvent.SELECTED);
      }
    });
    buttonPanel.add(menuBarCheckBox);
    add(buttonPanel, BorderLayout.SOUTH);
  }


  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 Main(), BorderLayout.CENTER);
        frame.setSize(800, 600);
        frame.setLocationByPlatform(true);
        frame.setVisible(true);
      }
    });
    NativeInterface.runEventPump();
  }

}
Turgut Tak
  • 43
  • 8
  • On other computer run it from console using command `java -jar myJar.jar`. Then you will see stacktrace in console. – Bedla Nov 12 '17 at 19:40
  • 1
    Possible duplicate of [how can I debug a jar at runtime?](https://stackoverflow.com/questions/19842322/how-can-i-debug-a-jar-at-runtime) – Bedla Nov 12 '17 at 19:44
  • I got below error. My computer is 64 bit. Is there a way to make the jar work both on 32bit and 64 bit? NativeSwing[1]: Exception in thread "main" java.lang.UnsatisfiedLinkError: Canno t load 64-bit SWT libraries on 32-bit JVM 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.(Unknown Source) ........................... – Turgut Tak Nov 12 '17 at 19:53

1 Answers1

0

Try to change the default JRE version to 32bit in eclipse. Or add -d32 to VM arguments in the "Edit launch configuration properties".

fhery021
  • 317
  • 2
  • 7