Index: applications/editors/josm/plugins/geotools/src/org/openstreetmap/josm/plugins/geotools/GeoToolsPlugin.java
===================================================================
--- applications/editors/josm/plugins/geotools/src/org/openstreetmap/josm/plugins/geotools/GeoToolsPlugin.java	(revision 30569)
+++ applications/editors/josm/plugins/geotools/src/org/openstreetmap/josm/plugins/geotools/GeoToolsPlugin.java	(revision 30734)
@@ -17,5 +17,13 @@
 import com.sun.media.jai.imageioimpl.ImageReadWriteSpi;
 
+/**
+ * GeoTools plugin, bringing this library to other JOSM plugins.
+ */
 public class GeoToolsPlugin extends Plugin {
+
+    /**
+     * Constructs a new {@code GeoToolsPlugin}.
+     * @param info plugin information
+     */
     public GeoToolsPlugin(PluginInformation info) {
         super(info);
@@ -29,5 +37,5 @@
         // See https://www.java.net/node/666373
         System.setProperty("com.sun.media.jai.disableMediaLib", "true");
-                
+
         // As the JAI jars are bundled in the geotools plugin, JAI initialization does not work,
         // so we need to perform the tasks described here ("Initialization and automatic loading of registry objects"):
@@ -35,34 +43,23 @@
         OperationRegistry registry = JAI.getDefaultInstance().getOperationRegistry();
         if (registry == null) {
-            System.err.println("geotools: error in JAI initialization. Cannot access default operation registry");
+            Main.error("geotools: error in JAI initialization. Cannot access default operation registry");
         } else {
             // Update registry with com.sun.media.jai.imageioimpl.ImageReadWriteSpi (only class listed javax.media.jai.OperationRegistrySpi)
-            // it would be safer to parse this file instead, but a JAI update is very unlikely as it has not been modified since 2005 
+            // it would be safer to parse this file instead, but a JAI update is very unlikely as it has not been modified since 2005
             new ImageReadWriteSpi().updateRegistry(registry);
 
-            // Update registry with GeoTools registry file 
-            InputStream in = GeoToolsPlugin.class.getResourceAsStream("/META-INF/registryFile.jai");
-            if (in == null) {
-                System.err.println("geotools: error in JAI initialization. Cannot access META-INF/registryFile.jai");
-            } else {
-                try {
+            // Update registry with GeoTools registry file
+            try (InputStream in = GeoToolsPlugin.class.getResourceAsStream("/META-INF/registryFile.jai")) {
+                if (in == null) {
+                    Main.error("geotools: error in JAI initialization. Cannot access META-INF/registryFile.jai");
+                } else {
                     registry.updateFromStream(in);
-                } catch (IOException e) {
-                    System.err.println("geotools: error in JAI initialization. Cannot update default operation registry");
                 }
-                try {
-                    in.close();
-                } catch (IOException e) {
-                    System.err.println("geotools: error in JAI initialization. Cannot close input stream");
-                }
+            } catch (IOException e) {
+                Main.error("geotools: error in JAI initialization: "+e.getMessage());
             }
-            
-            // Print JAI registry contents
-            //for (String mode : RegistryMode.getModeNames()) {
-            //    System.out.println("geotools: JAI mode "+mode+": "+Arrays.toString(registry.getDescriptorNames(mode)));
-            //}
         }
     }
-    
+
     private void initGeoTools() {
         // Force Axis order. Fix #8248
