0

I have been programming a GUI to display data from sensors.

The gui includes a google map visualizer displaying the data with markers (through gps readings).

I had been passing in the readings in through the url by using '?' and '&':

    String url = this.getClass().getResource("/resources/map.html").toExternalForm();
    url +="?";
    for (GPSReading r : data) {
        // remove all aplhabetic characters, except for S and E (for lon
        // lat) then trim the white spaces
        // pass it into the url to be processed by js
        url += r.toString().trim().replaceAll("[^\\d.ES ]", "").replaceFirst("S", "");
        url += '&';
    }

and then loading it in the WebEngine

webEngine.load(url);

This works fine when run through eclipse, but when I pack the code into an executable jar, the link breaks and nothing displays on the webEngine.

This is the js code where I retrieve the parameters form the url:

    var parameters = window.location.href;
    parameters= decodeURI(parameters.split("?")[1]);
    var paramArray = parameters.split('&');
    [...]
     var field = paramArray[reading].split(" ").filter(Boolean);

And then I go ahead and do some string parsing which works fine.

Would anybody know why passing the parameters through the url works from eclipse but not from the Jar, is there anyway to make this work ?

Edit

I checked the jar and it contains the only external library I have used (RxTx) I did the rest with the java standard library.

Hypnic Jerk
  • 1,192
  • 3
  • 14
  • 32
  • Have you looked at GMapsFX? It's a JavaFX wrapper that would allow you to place markers directly from java. http://rterp.github.io/GMapsFX/ – Geoff Oct 24 '16 at 03:35

1 Answers1

0

Did you check the jar which is made is made by eclipse has all the required classes and external libraries you need. It might be a issue wih external libraries not being present. You then need to make a fat jar for the file with all your dependencies

Rahul Singh
  • 19,030
  • 11
  • 64
  • 86
  • Hi thanks for the reply, I am generating the jar through eclipse, so I am not too sure. How ever I have been testing and if I don't put the parameters in the url the map loads fine (obviously without the markers). I am looking into re-writting my js functio nand calling WebEngiexecute script to pass the para – Marco Lindley Oct 23 '16 at 05:30
  • calling WebEngine.executeScript to pass the parameters in * – Marco Lindley Oct 23 '16 at 05:31