![]() |
Main /
JavaTracingStack trace:
Heap dump (if hung)
Threadsafe tips:
logging
#include org.apache.log4j.Logger;
public class Bla() {
private Logger log;
public Bla() {
log = Logger.getLogger(Bla.class);
}
public someMethod() {
if (log.isDebugEnabled()) {
log.debug("haha");
}
log.warn("warning");
}
}
starting a java process from java
private void startInJava(long eventId, boolean wait) {
String ini = System.getProperty("borland.copyenv.bos.inifile");
String user = System.getProperty("borland.copyenv.bos.username");
String pass = System.getProperty("borland.copyenv.bos.password");
String classPath = System.getProperty("java.class.path");
String javaHome = System.getProperty("java.home");
String javacHome = javaHome.replaceAll("Program Files", "PROGRA~1").replaceAll("jre", "bin");
if (log.isDebugEnabled()) {
log.debug("Starting the in running manager - Java mode");
log.debug("ini param = " + ini);
log.debug("user = " + user);
log.debug("EventId = " + eventId);
log.debug("javaHome = " + javaHome);
log.debug("CLASSPATH = " + classPath);
}
String strEventId = "" + eventId;
/* TODO : check that OS is XP */
String[] cmd = { "cmd.exe", "/C", javacHome + File.separator + "java", "-verbose", "-classpath", classPath, "-Dborland.copyenv.bos.inifile=" + ini, "-Dborland.copyenv.bos.username=" + user, "-Dborland.copyenv.bos.password=" + pass, "com.vcint.inrunning.gui.InRunningClient", strEventId };
Runtime r = Runtime.getRuntime();
Process proc = null;
try {
proc = r.exec(cmd);
startGobblers(proc);
if (wait) {
// this logs the processes output
int exitVal = proc.waitFor();
}
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
if (wait) {
try {
proc.getInputStream().close();
proc.getOutputStream().close();
proc.getErrorStream().close();
} catch (Exception e) {
// ignore
}
}
}
} // startInJava()
|