Menu

#18 Can not set xulrunner path as system property

v1.0_(example)
closed
nobody
None
1
2017-10-19
2017-10-18
No

I put xulrunner folder inside my project (in a folder called native). Now I'm trying to add xulrunner paths to the project as follows:

File xulRunner = new File("native//xulrunner");
System.setProperty("-Dnativeswing.webbrowser.runtime", "xulrunner");
System.setProperty("-Dnativeswing.webbrowser.xulrunner.home", xulRunner.getAbsolutePath());

It does not work, and I'm getting this error:

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at chrriis.dj.nativeswing.swtimpl.core.MessagingInterface.processCommandResult(MessagingInterface.java:342)
    at chrriis.dj.nativeswing.swtimpl.core.MessagingInterface.syncSend(MessagingInterface.java:329)
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.syncSend_(SWTNativeInterface.java:392)
    at chrriis.dj.nativeswing.swtimpl.NativeInterface.syncSend(NativeInterface.java:104)

It works, If I write the path as an absolute path which directs to the folder in my pc, like:

System.setProperty("-Dnativeswing.webbrowser.xulrunner.home", "C:/folder/folder/folder/projectfolder/native/xulrunner");

It is strange because I check the xulRunner.getAbsolutePath() value with debug and It has the same value with this path. But does not work.

Discussion

  • CUMHUR KILIÇ

    CUMHUR KILIÇ - 2017-10-18

    Sorry I miswrote the last part.

    This does not work either:

    System.setProperty("-Dnativeswing.webbrowser.xulrunner.home", "C:/folder/folder/folder/projectfolder/native/xulrunner");
    

    What I meant to write was that It works when I add this full path to the project VM Options:

    -Dnativeswing.webbrowser.runtime="xulrunner" -Dnativeswing.webbrowser.xulrunner.home="C:/folder/folder/folder/projectfolder/native/xulrunner"
    
     
  • Tony

    Tony - 2017-10-18

    I think you set your properties too late.

    Try setting your properties before calling to NativeInterface.open()

     
    • CUMHUR KILIÇ

      CUMHUR KILIÇ - 2017-10-18

      well basicly the code goes like :

              System.setProperty("-Dnativeswing.webbrowser.runtime", "xulrunner");
              System.setProperty("-Dnativeswing.webbrowser.xulrunner.home", "native/xulrunner");
      
              try {
                  webBrowserPanel = new JPanel(new BorderLayout());
                  webBrowserPanel.removeAll();
      
                  NativeInterface.open();
      
      .
      .
      
       
  • Christopher Deckers

    Hi,

    Then maybe try setting the properties before calling NativeInterface.initialize().

    If that does not work, set that code as first line of main method.

    Hope this helps,
    -Christopher

     
    • CUMHUR KILIÇ

      CUMHUR KILIÇ - 2017-10-18

      I'll try,but which path should I use.
      I expect "native/xulrunner" to work normally. Do you confirm this ?

       
    • CUMHUR KILIÇ

      CUMHUR KILIÇ - 2017-10-18

      This method is the first thing I call in my main method:

      public static void loadNativePaths() {
              System.setProperty("jna.nosys", TRUE);
              System.setProperty("jna.boot.library.path", "lib");
              System.setProperty("jna.library.path", "native");
              File nativeDir = new File("native/plugins/");
      
              File file = new File("native/xulrunner");
              System.setProperty("-Dnativeswing.webbrowser.runtime", "xulrunner");
              System.setProperty("-Dnativeswing.webbrowser.xulrunner.home", file.getAbsolutePath());
      
              NativeInterface.initialize();
          }
      

      Later when needed I call

      NativeInterface.open();

       
  • Tony

    Tony - 2017-10-18

    You don't have to put "-D" when using setProperty function so :

    System.setProperty("-Dnativeswing.webbrowser.runtime", "xulrunner");
    System.setProperty("-Dnativeswing.webbrowser.xulrunner.home", xulRunner.getAbsolutePath());
    

    need to be replaced by :

    System.setProperty("nativeswing.webbrowser.runtime", "xulrunner");
    System.setProperty("nativeswing.webbrowser.xulrunner.home", xulRunner.getAbsolutePath());
    
     
  • CUMHUR KILIÇ

    CUMHUR KILIÇ - 2017-10-19

    Placing these before NativeInterface.open() and correction of -D solved my problem.
    Thanks a lot for your time.

     
  • Christopher Deckers

    • Status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB