*/
package jalview.bin;
-import jalview.datamodel.PDBEntry;
-import jalview.gui.UserDefinedColours;
-import jalview.schemes.ColourSchemeLoader;
-import jalview.schemes.ColourSchemes;
-import jalview.schemes.UserColourScheme;
-import jalview.structure.StructureImportSettings;
-import jalview.urls.IdOrgSettings;
-import jalview.util.ColorUtils;
-import jalview.ws.sifts.SiftsSettings;
-
import java.awt.Color;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.TreeSet;
+import java.util.regex.Pattern;
+
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.SimpleLayout;
+import jalview.datamodel.PDBEntry;
+import jalview.gui.UserDefinedColours;
+import jalview.schemes.ColourSchemeLoader;
+import jalview.schemes.ColourSchemes;
+import jalview.schemes.UserColourScheme;
+import jalview.structure.StructureImportSettings;
+import jalview.urls.IdOrgSettings;
+import jalview.util.ColorUtils;
+import jalview.ws.sifts.SiftsSettings;
+
/**
* Stores and retrieves Jalview Application Properties Lists and fields within
* list entries are separated by '|' symbols unless otherwise stated (|) clauses
String jnlpVersion = System.getProperty("jalview.version");
- // jnlpVersion will be null if a latest version check for the channel needs to
- // be done
+ // jnlpVersion will be null if a latest version check for the channel needs
+ // to be done
// Dont do this check if running in headless mode
if (jnlpVersion == null && getDefault("VERSION_CHECK", true)
new BuildDetails(codeVersion, null, codeInstallation);
if (printV && reportVersion)
{
- System.out
- .println("Jalview Version: " + codeVersion + codeInstallation);
+ System.out.println(
+ "Jalview Version: " + codeVersion + codeInstallation);
}
}
}
/**
+ * Initial logging information helper for various versions output
+ *
+ * @param prefix
+ * @param value
+ * @param defaultValue
+ */
+ private static void appendIfNotNull(StringBuilder sb, String prefix,
+ String value, String suffix, String defaultValue)
+ {
+ if (value == null && defaultValue == null)
+ {
+ return;
+ }
+ String line = prefix + (value != null ? value : defaultValue) + suffix;
+ sb.append(line);
+ }
+
+ /**
*
* @return Jalview version, build details and JVM platform version for console
*/
public static String getVersionDetailsForConsole()
{
- return "Jalview Version: "
- + jalview.bin.Cache.getDefault("VERSION", "TEST")
- + "\n" + "Jalview Installation: "
- + jalview.bin.Cache.getDefault("INSTALLATION",
- "unknown")
- + "\n" + "Build Date: "
- + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown")
- + "\n" + "Java version: "
- + System.getProperty("java.version") + "\n"
- + System.getProperty("os.arch") + " "
+ StringBuilder sb = new StringBuilder();
+ sb.append("Jalview Version: "
+ + jalview.bin.Cache.getDefault("VERSION", "TEST"));
+ sb.append("\n");
+ sb.append("Jalview Installation: "
+ + jalview.bin.Cache.getDefault("INSTALLATION", "unknown"));
+ sb.append("\n");
+ sb.append("Build Date: "
+ + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"));
+ sb.append("\n");
+ sb.append("Java version: " + System.getProperty("java.version"));
+ sb.append("\n");
+ sb.append(System.getProperty("os.arch") + " "
+ System.getProperty("os.name") + " "
- + System.getProperty("os.version")
- + (jalview.bin.Cache.getDefault("VERSION", "TEST")
- .equals("DEVELOPMENT")
- ? "\nGetdown appdir: " + System.getProperty("getdownappdir") + "\nJava path: "
- + System.getProperty(
- "java.home")
- + File.separator + "bin"
- + File.separator + "java"
- : "");
+ + System.getProperty("os.version"));
+ sb.append("\n");
+ appendIfNotNull(sb, "Install4j version: ",
+ System.getProperty("sys.install4jVersion"), "\n", null);
+ appendIfNotNull(sb, "Install4j template version: ",
+ System.getProperty("installer_template_version"), "\n", null);
+ appendIfNotNull(sb, "Launcher version: ",
+ System.getProperty("launcher_version"), "\n", null);
+ LookAndFeel laf = UIManager.getLookAndFeel();
+ String lafName = laf == null ? "Not obtained" : laf.getName();
+ String lafClass = laf == null ? "unknown" : laf.getClass().getName();
+ appendIfNotNull(sb, "LookAndFeel: ", lafName + " (" + lafClass + ")",
+ "\n", null);
+ // Not displayed in release version ( determined by possible version number
+ // regex 9[9.]*9[.-_a9]* )
+ if (Pattern.matches("^\\d[\\d\\.]*\\d[\\.\\-\\w]*$",
+ jalview.bin.Cache.getDefault("VERSION", "TEST")))
+ {
+ appendIfNotNull(sb, "Getdown appdir: ",
+ System.getProperty("getdownappdir"), "\n", null);
+ appendIfNotNull(sb, "Java home: ", System.getProperty("java.home"),
+ "\n", "unknown");
+ }
+ return sb.toString();
}
/**
// eg 'built from Source' or update channel
return jalview.bin.Cache.getDefault("INSTALLATION", "unknown");
}
+
+ public static String getStackTraceString(Throwable t)
+ {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ t.printStackTrace(pw);
+ return sw.toString();
+ }
}