Exemple #1
0
 /**
  * Returns an information string for an unexpected exception.
  *
  * @param ex exception
  * @return dummy object
  */
 public static String bug(final Throwable ex) {
   final TokenBuilder tb = new TokenBuilder(BUGINFO);
   tb.add(NL).add("Contact: ").add(MAIL);
   tb.add(NL).add("Version: ").add(TITLE);
   tb.add(NL).add("Java: ").add(System.getProperty("java.vendor"));
   tb.add(", ").add(System.getProperty("java.version"));
   tb.add(NL).add("OS: ").add(System.getProperty("os.name"));
   tb.add(", ").add(System.getProperty("os.arch"));
   tb.add(NL).add("Stack Trace: ");
   for (final String e : toArray(ex)) tb.add(NL).add(e);
   return tb.toString();
 }
Exemple #2
0
  /**
   * Starts the specified class in a separate process.
   *
   * @param clz class to start
   * @param args command-line arguments
   * @return reference to a {@link Process} instance representing the started process
   */
  public static Process start(final Class<?> clz, final String... args) {
    final String[] largs = {
      "java",
      "-Xmx" + Runtime.getRuntime().maxMemory(),
      "-cp",
      System.getProperty("java.class.path"),
      clz.getName(),
      "-D",
    };
    final StringList sl = new StringList().add(largs).add(args);

    try {
      return new ProcessBuilder(sl.toArray()).start();
    } catch (final IOException ex) {
      notexpected(ex);
      return null;
    }
  }
Exemple #3
0
 /**
  * Sets the specified value if property has not been set yet.
  *
  * @param key property key
  * @param value property value
  * @param force force setting
  */
 private void set(final String key, final Object value, final boolean force) {
   if (force || System.getProperty(key) == null) {
     System.setProperty(key, value.toString());
   }
 }