Index: /applications/editors/josm/plugins/geochat/build.xml
===================================================================
--- /applications/editors/josm/plugins/geochat/build.xml	(revision 30233)
+++ /applications/editors/josm/plugins/geochat/build.xml	(revision 30234)
@@ -5,5 +5,5 @@
     <property name="commit.message" value="[josm_geochat] copypaste from keyboard, font size advanced parameters"/>
     <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
-    <property name="plugin.main.version" value="6484"/>
+    <property name="plugin.main.version" value="6756"/>
 
     <property name="plugin.author" value="Ilya Zverev"/>
Index: /applications/editors/josm/plugins/geochat/src/geochat/ChatServerConnection.java
===================================================================
--- /applications/editors/josm/plugins/geochat/src/geochat/ChatServerConnection.java	(revision 30233)
+++ /applications/editors/josm/plugins/geochat/src/geochat/ChatServerConnection.java	(revision 30234)
@@ -15,7 +15,8 @@
 import java.util.Set;
 
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
+import javax.json.JsonArray;
+import javax.json.JsonException;
+import javax.json.JsonObject;
+
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.coor.CoordinateFormat;
@@ -92,6 +93,6 @@
             String query = "whoami&uid=" + uid;
             JsonQueryUtil.queryAsync(query, new JsonQueryCallback() {
-                public void processJson( JSONObject json ) {
-                    if( json != null && json.has("name") )
+                public void processJson( JsonObject json ) {
+                    if( json != null && json.get("name") != null )
                         login(uid, json.getString("name"));
                     else if( userName != null && userName.length() > 1 )
@@ -143,13 +144,13 @@
                     + nameAttr;
             JsonQueryUtil.queryAsync(query, new JsonQueryCallback() {
-                public void processJson( JSONObject json ) {
+                public void processJson( JsonObject json ) {
                     if( json == null )
                         fireLoginFailed(tr("Could not get server response, check logs"));
-                    else if( json.has("error") )
+                    else if( json.get("error") != null )
                         fireLoginFailed(tr("Failed to login as {0}:", userName) + "\n" + json.getString("error"));
-                    else if( !json.has("uid") )
+                    else if( json.get("uid") == null)
                         fireLoginFailed(tr("The server did not return user ID"));
                     else {
-                        String name = json.has("name") ? json.getString("name") : userName;
+                        String name = json.get("name") != null ? json.getString("name") : userName;
                         login(json.getInt("uid"), name);
                     }
@@ -190,6 +191,6 @@
         String query = "logout&uid=" + userId;
         JsonQueryUtil.queryAsync(query, new JsonQueryCallback() {
-            public void processJson( JSONObject json ) {
-                if( json != null && json.has("message") ) {
+            public void processJson( JsonObject json ) {
+                if( json != null && json.get("message") != null) {
                     logoutIntl();
                 }
@@ -245,8 +246,8 @@
                     query += "&to=" + URLEncoder.encode(targetUser, "UTF8");
             JsonQueryUtil.queryAsync(query, new JsonQueryCallback() {
-                public void processJson( JSONObject json ) {
+                public void processJson( JsonObject json ) {
                     if( json == null )
                         fireMessageFailed(tr("Could not get server response, check logs"));
-                    else if( json.has("error") )
+                    else if( json.get("error") != null )
                         fireMessageFailed(tr("Failed to send message:") + "\n" + json.getString("error"));
                 }
@@ -356,5 +357,5 @@
                     + "&lon=" + pos.lonToString(CoordinateFormat.DECIMAL_DEGREES)
                     + "&uid=" + userId + "&last=" + lastId;
-            JSONObject json;
+            JsonObject json;
             try {
                 json = JsonQueryUtil.query(query);
@@ -366,15 +367,15 @@
 //              fireLoginFailed(tr("Could not get server response, check logs"));
 //              logoutIntl(); // todo: uncomment?
-            } else if( json.has("error") ) {
+            } else if( json.get("error") != null) {
                 fireLoginFailed(tr("Failed to get messages as {0}:", userName) + "\n" + json.getString("error"));
                 logoutIntl();
             } else {
-                if( json.has("users") ) {
-                    Map<String, LatLon> users = parseUsers(json.getJSONArray("users"));
+                if( json.get("users") != null) {
+                    Map<String, LatLon> users = parseUsers(json.getJsonArray("users"));
                     for( ChatServerConnectionListener listener : listeners )
                         listener.updateUsers(users);
                 }
-                if( json.has("messages") ) {
-                    List<ChatMessage> messages = parseMessages(json.getJSONArray("messages"), false);
+                if( json.get("messages") != null) {
+                    List<ChatMessage> messages = parseMessages(json.getJsonArray("messages"), false);
                     for( ChatMessage m : messages )
                         if( m.getId() > lastId )
@@ -383,6 +384,6 @@
                         listener.receivedMessages(needReset, messages);
                 }
-                if( json.has("private") ) {
-                    List<ChatMessage> messages = parseMessages(json.getJSONArray("private"), true);
+                if( json.get("private") != null) {
+                    List<ChatMessage> messages = parseMessages(json.getJsonArray("private"), true);
                     for( ChatMessage m : messages )
                         if( m.getId() > lastId )
@@ -396,13 +397,13 @@
         }
 
-        private List<ChatMessage> parseMessages( JSONArray messages, boolean priv ) {
+        private List<ChatMessage> parseMessages( JsonArray messages, boolean priv ) {
             List<ChatMessage> result = new ArrayList<ChatMessage>();
-            for( int i = 0; i < messages.length(); i++ ) {
+            for( int i = 0; i < messages.size(); i++ ) {
                 try {
-                    JSONObject msg = messages.getJSONObject(i);
-                    long id = msg.getLong("id");
-                    double lat = msg.getDouble("lat");
-                    double lon = msg.getDouble("lon");
-                    long timeStamp = msg.getLong("timestamp");
+                	JsonObject msg = messages.getJsonObject(i);
+                    long id = msg.getJsonNumber("id").longValue();
+                    double lat = msg.getJsonNumber("lat").doubleValue();
+                    double lon = msg.getJsonNumber("lon").doubleValue();
+                    long timeStamp = msg.getJsonNumber("timestamp").longValue();
                     String author = msg.getString("author");
                     String message = msg.getString("message");
@@ -411,8 +412,8 @@
                             incoming, message, new Date(timeStamp * 1000));
                     cm.setPrivate(priv);
-                    if( msg.has("recipient") && !incoming )
+                    if( msg.get("recipient") != null && !incoming )
                         cm.setRecipient(msg.getString("recipient"));
                     result.add(cm);
-                } catch( JSONException e ) {
+                } catch( JsonException e ) {
                     // do nothing, just skip this message
                 }
@@ -421,14 +422,14 @@
         }
 
-        private Map<String, LatLon> parseUsers( JSONArray users ) {
+        private Map<String, LatLon> parseUsers( JsonArray users ) {
             Map<String, LatLon> result = new HashMap<String, LatLon>();
-            for( int i = 0; i < users.length(); i++ ) {
+            for( int i = 0; i < users.size(); i++ ) {
                 try {
-                    JSONObject user = users.getJSONObject(i);
+                	JsonObject user = users.getJsonObject(i);
                     String name = user.getString("user");
-                    double lat = user.getDouble("lat");
-                    double lon = user.getDouble("lon");
+                    double lat = user.getJsonNumber("lat").doubleValue();
+                    double lon = user.getJsonNumber("lon").doubleValue();
                     result.put(name, new LatLon(lat, lon));
-                } catch( JSONException e ) {
+                } catch( JsonException e ) {
                     // do nothing, just skip this user
                 }
Index: /applications/editors/josm/plugins/geochat/src/geochat/JsonQueryCallback.java
===================================================================
--- /applications/editors/josm/plugins/geochat/src/geochat/JsonQueryCallback.java	(revision 30233)
+++ /applications/editors/josm/plugins/geochat/src/geochat/JsonQueryCallback.java	(revision 30234)
@@ -2,5 +2,5 @@
 package geochat;
 
-import org.json.JSONObject;
+import javax.json.JsonObject;
 
 /**
@@ -17,4 +17,4 @@
      * @param json JSON parsed response or null if the query was unsuccessful.
      */
-    void processJson( JSONObject json );
+    void processJson( JsonObject json );
 }
Index: /applications/editors/josm/plugins/geochat/src/geochat/JsonQueryUtil.java
===================================================================
--- /applications/editors/josm/plugins/geochat/src/geochat/JsonQueryUtil.java	(revision 30233)
+++ /applications/editors/josm/plugins/geochat/src/geochat/JsonQueryUtil.java	(revision 30234)
@@ -8,7 +8,9 @@
 import java.net.MalformedURLException;
 import java.net.URL;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.json.JSONTokener;
+
+import javax.json.Json;
+import javax.json.JsonException;
+import javax.json.JsonObject;
+
 import org.openstreetmap.josm.Main;
 
@@ -23,8 +25,8 @@
      * Query the server synchronously.
      * @param query Query string, starting with action. Example: <tt>get&lat=1.0&lon=-2.0&uid=12345</tt>
-     * @return Parsed JSONObject if the query was successful, <tt>null</tt> otherwise.
+     * @return Parsed JsonObject if the query was successful, <tt>null</tt> otherwise.
      * @throws IOException There was a problem connecting to the server or parsing JSON.
      */
-    public static JSONObject query( String query ) throws IOException {
+    public static JsonObject query( String query ) throws IOException {
         try {
             String serverURL = Main.pref.get("geochat.server", "http://zverik.dev.openstreetmap.org/osmochat.php?action=");
@@ -40,8 +42,6 @@
                 throw new IOException("Empty response");
             try {
-                JSONTokener tokener = new JSONTokener(inp);
-                JSONObject result = new JSONObject(tokener);
-                return result;
-            } catch( JSONException e ) {
+                return Json.createReader(inp).readObject();
+            } catch( JsonException e ) {
                 throw new IOException("Failed to parse JSON: " + e.getMessage());
             } finally {
@@ -75,5 +75,5 @@
 
     private void doRealRun() {
-        JSONObject obj;
+    	JsonObject obj;
         try {
             obj = query(query);
Index: /applications/editors/josm/plugins/livegps/build.xml
===================================================================
--- /applications/editors/josm/plugins/livegps/build.xml	(revision 30233)
+++ /applications/editors/josm/plugins/livegps/build.xml	(revision 30234)
@@ -2,5 +2,5 @@
 <project name="livegps" default="dist" basedir=".">
     <property name="commit.message" value="Changed the constructor signature of the plugin main class"/>
-    <property name="plugin.main.version" value="6484"/>
+    <property name="plugin.main.version" value="6756"/>
 	
     <!-- Configure these properties (replace "..." accordingly).
Index: /applications/editors/josm/plugins/livegps/src/livegps/LiveGpsAcquirer.java
===================================================================
--- /applications/editors/josm/plugins/livegps/src/livegps/LiveGpsAcquirer.java	(revision 30233)
+++ /applications/editors/josm/plugins/livegps/src/livegps/LiveGpsAcquirer.java	(revision 30234)
@@ -2,5 +2,4 @@
 
 import static org.openstreetmap.josm.tools.I18n.tr;
-
 
 import java.beans.PropertyChangeEvent;
@@ -9,4 +8,5 @@
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.io.StringReader;
 import java.net.InetAddress;
 import java.net.Socket;
@@ -14,8 +14,10 @@
 import java.util.List;
 
+import javax.json.Json;
+import javax.json.JsonException;
+import javax.json.JsonNumber;
+import javax.json.JsonObject;
+
 import org.openstreetmap.josm.Main;
-
-import org.json.JSONObject;
-import org.json.JSONException;
 
 public class LiveGpsAcquirer implements Runnable {
@@ -41,5 +43,4 @@
      */
     public LiveGpsAcquirer() {
-        super();
 
         gpsdHost = Main.pref.get(C_HOST, DEFAULT_HOST);
@@ -77,6 +78,5 @@
      * @param statusMessage the status message.
      */
-    public void fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus status,
-            String statusMessage) {
+    public void fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus status, String statusMessage) {
         PropertyChangeEvent event = new PropertyChangeEvent(this, "gpsstatus",
                 null, new LiveGpsStatus(status, statusMessage));
@@ -97,6 +97,5 @@
      */
     public void fireGpsDataChangeEvent(LiveGpsData oldData, LiveGpsData newData) {
-        PropertyChangeEvent event = new PropertyChangeEvent(this, "gpsdata",
-                oldData, newData);
+        PropertyChangeEvent event = new PropertyChangeEvent(this, "gpsdata", oldData, newData);
 
         if (!event.equals(lastDataEvent)) {
@@ -124,44 +123,46 @@
         while (!shutdownFlag) {
 
-	    while (!connected) {
-		try {
+            while (!connected) {
+                try {
                     connect();
-		} catch (IOException iox) {
-		    fireGpsStatusChangeEvent( LiveGpsStatus.GpsStatus.CONNECTION_FAILED, tr("Connection Failed"));
-                    try {
-                        Thread.sleep(1000);
-                    } catch (InterruptedException ignore) {}
-		}
-	    }
-
-	    assert (connected);
-
-	    try {
-                    String line;
-
-                    // <FIXXME date="23.06.2007" author="cdaller">
-                    // TODO this read is blocking if gps is connected but has no
-                    // fix, so gpsd does not send positions
-                    line = gpsdReader.readLine();
-                    // </FIXXME>
-                    if (line == null)
-                        throw new IOException();
-
-                    if (JSONProtocol == true)
-                        gpsData = ParseJSON(line);
-                    else
-                        gpsData = ParseOld(line);
-
-                    if (gpsData == null)
-                        continue;
-
-                    fireGpsDataChangeEvent(oldGpsData, gpsData);
-                    oldGpsData = gpsData;
+                } catch (IOException iox) {
+                    fireGpsStatusChangeEvent( LiveGpsStatus.GpsStatus.CONNECTION_FAILED, tr("Connection Failed"));
+	                try {
+	                    Thread.sleep(1000);
+	                } catch (InterruptedException ignore) {
+	                	
+	                }
+	            }
+            }
+
+            assert (connected);
+
+            try {
+                String line;
+
+                // <FIXXME date="23.06.2007" author="cdaller">
+                // TODO this read is blocking if gps is connected but has no
+                // fix, so gpsd does not send positions
+                line = gpsdReader.readLine();
+                // </FIXXME>
+                if (line == null)
+                    throw new IOException();
+
+                if (JSONProtocol == true)
+                    gpsData = ParseJSON(line);
+                else
+                    gpsData = ParseOld(line);
+
+                if (gpsData == null)
+                    continue;
+
+                fireGpsDataChangeEvent(oldGpsData, gpsData);
+                oldGpsData = gpsData;
             } catch (IOException iox) {
-                System.out.println("LiveGps: lost connection to gpsd");
+                Main.warn("LiveGps: lost connection to gpsd");
                 fireGpsStatusChangeEvent(
                         LiveGpsStatus.GpsStatus.CONNECTION_FAILED,
                         tr("Connection Failed"));
-		disconnect();
+                disconnect();
                 try {
                     Thread.sleep(1000);
@@ -171,8 +172,8 @@
         }
 
-	System.out.println("LiveGps: Disconnected from gpsd");
+        Main.info("LiveGps: Disconnected from gpsd");
         fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.DISCONNECTED,
                 tr("Not connected"));
-	disconnect();
+        disconnect();
     }
 
@@ -182,8 +183,8 @@
 
     private void connect() throws IOException {
-        JSONObject greeting;
+        JsonObject greeting;
         String line, type, release;
 
-        System.out.println("LiveGps: trying to connect to gpsd at " + gpsdHost + ":" + gpsdPort);
+        Main.info("LiveGps: trying to connect to gpsd at " + gpsdHost + ":" + gpsdPort);
         fireGpsStatusChangeEvent( LiveGpsStatus.GpsStatus.CONNECTING, tr("Connecting"));
 
@@ -194,5 +195,5 @@
                 break;
             } catch (IOException e) {
-                System.out.println("LiveGps: Could not open connection to gpsd: " + e);
+            	Main.warn("LiveGps: Could not open connection to gpsd: " + e);
                 gpsdSocket = null;
             }
@@ -213,16 +214,16 @@
 
         try {
-            greeting = new JSONObject(line);
+            greeting = Json.createReader(new StringReader(line)).readObject();
             type = greeting.getString("class");
             if (type.equals("VERSION")) {
                 release = greeting.getString("release");
-                System.out.println("LiveGps: Connected to gpsd " + release);
+                Main.info("LiveGps: Connected to gpsd " + release);
             } else
-                System.out.println("LiveGps: Unexpected JSON in gpsd greeting: " + line);
-        } catch (JSONException jex) {
+            	Main.info("LiveGps: Unexpected JSON in gpsd greeting: " + line);
+        } catch (JsonException jex) {
             if (line.startsWith("GPSD,")) {
                 connected = true;
                 JSONProtocol = false;
-                System.out.println("LiveGps: Connected to old gpsd protocol version.");
+                Main.info("LiveGps: Connected to old gpsd protocol version.");
                 fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.CONNECTED, tr("Connected"));
             }
@@ -230,9 +231,8 @@
 
         if (JSONProtocol == true) {
-            JSONObject Watch = new JSONObject();
-            try {
-                Watch.put("enable", true);
-                Watch.put("json", true);
-            } catch (JSONException je) {}
+        	JsonObject Watch = Json.createObjectBuilder()
+        			.add("enable", true)
+        			.add("json", true)
+        			.build();
 
             String Request = "?WATCH=" + Watch.toString() + ";\n";
@@ -245,18 +245,18 @@
 
     private void disconnect() {
-	assert(gpsdSocket != null);
-
-	connected = false;
+        assert(gpsdSocket != null);
+
+        connected = false;
 
         try {
-		gpsdSocket.close();
-		gpsdSocket = null;
-	} catch (Exception e) {
-		System.out.println("LiveGps: Unable to close socket; reconnection may not be possible");
-	}
+            gpsdSocket.close();
+            gpsdSocket = null;
+        } catch (Exception e) {
+        	Main.warn("LiveGps: Unable to close socket; reconnection may not be possible");
+        }
     }
 
     private LiveGpsData ParseJSON(String line) {
-        JSONObject report;
+        JsonObject report;
         String type;
         double lat = 0;
@@ -268,8 +268,8 @@
 
         try {
-            report = new JSONObject(line);
+            report = Json.createReader(new StringReader(line)).readObject();
             type = report.getString("class");
-        } catch (JSONException jex) {
-            System.out.println("LiveGps: line read from gpsd is not a JSON object:" + line);
+        } catch (JsonException jex) {
+        	Main.warn("LiveGps: line read from gpsd is not a JSON object:" + line);
             return null;
         }
@@ -278,15 +278,19 @@
 
         try {
-            lat = report.getDouble("lat");
-            lon = report.getDouble("lon");
-            speed = (new Float(report.getDouble("speed"))).floatValue();
-            course = (new Float(report.getDouble("track"))).floatValue();
-	    if (report.has("epx"))
-		epx = (new Float(report.getDouble("epx"))).floatValue();
-	    if (report.has("epy"))
-		epy = (new Float(report.getDouble("epy"))).floatValue();
+            lat = report.getJsonNumber("lat").doubleValue();
+            lon = report.getJsonNumber("lon").doubleValue();
+            speed = (new Float(report.getJsonNumber("speed").doubleValue())).floatValue();
+            course = (new Float(report.getJsonNumber("track").doubleValue())).floatValue();
+            JsonNumber epxJson = report.getJsonNumber("epx");
+            if (epxJson != null)
+                epx = (new Float(epxJson.doubleValue())).floatValue();
+            JsonNumber epyJson = report.getJsonNumber("epy");
+            if (epyJson != null)
+                epy = (new Float(epyJson.doubleValue())).floatValue();
 
             return new LiveGpsData(lat, lon, course, speed, epx, epy);
-        } catch (JSONException je) {}
+        } catch (JsonException je) {
+        	Main.debug(je.getMessage());
+        }
 
         return null;
