JAL-3210 merge. j2sclasslist_jmol seems to be removed
[jalview.git] / src / jalview / bin / Cache.java
index 9e28f5d..94a1825 100755 (executable)
@@ -38,6 +38,7 @@ import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.net.URL;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Collections;
@@ -396,13 +397,13 @@ public class Cache
     }
 
     // LOAD THE AUTHORS FROM THE authors.props file
-    String authorDetails = resolveResourceURLFor("authors.props");
+    String authorDetails = resolveResourceURLFor("/authors.props");
 
     try
     {
       if (authorDetails != null)
       {
-        java.net.URL localJarFileURL = new java.net.URL(authorDetails);
+        URL localJarFileURL = new URL(authorDetails);
         InputStream in = localJarFileURL.openStream();
         applicationProperties.load(in);
         in.close();
@@ -542,7 +543,8 @@ public class Cache
         url = Cache.class.getResource(resourcePath).toString();
       } catch (Exception ex)
       {
-
+        System.err.println("Failed to resolve resource " + resourcePath + ": "
+                + ex.getMessage());
       }
     }
     else
@@ -556,17 +558,16 @@ public class Cache
   public static void loadBuildProperties(boolean reportVersion)
   {
     String codeInstallation = getProperty("INSTALLATION");
-    boolean printV = codeInstallation == null;
+    boolean printVersion = codeInstallation == null;
 
-    // FIND THE VERSION NUMBER AND BUILD DATE FROM jalview.jar
+    /*
+     * read build properties - from the Jalview jar for a Java distribution,
+     * or from codebase file in test or JalviewJS context
+     */
     try
     {
-      String buildDetails = "jar:".concat(Cache.class.getProtectionDomain()
-              .getCodeSource().getLocation().toString()
-              .concat("!/.build_properties"));
-
-      java.net.URL localJarFileURL = new java.net.URL(buildDetails);
-
+      String buildDetails = resolveResourceURLFor("/.build_properties");
+      URL localJarFileURL = new URL(buildDetails);
       InputStream in = localJarFileURL.openStream();
       applicationProperties.load(in);
       in.close();
@@ -590,7 +591,7 @@ public class Cache
     }
     setProperty("VERSION", codeVersion);
     new BuildDetails(codeVersion, null, codeInstallation);
-    if (printV && reportVersion)
+    if (printVersion && reportVersion)
     {
       System.out
             .println("Jalview Version: " + codeVersion + codeInstallation);