I am trying to spawn a process using Runtime.exec. I want to use my current classpath : System.getProperty("java.class.path")
Unfortunately, I am having all kinds of issues. When it works on my mac, it doesn't work on Windows. And doesn't work on my mac ever when there is a space in the classpath. The error I always get is ClassDefNotFound, so it's related to how I'm building and passing in the classpath.
here is some sample code:
String startClass = "com.test.MyClass"
String javaHome = System.getProperty("java.home");
String javaCmd = javaHome + "/bin/java";
String classPath = "-Djava.class.path=" + System.getProperty("java.class.path");
String[] commands = new String[]{javaCmd, classPath, startClass};
String commandString = StringUtils.join(commands, " ");
Process process = Runtime.getRuntime().exec(commandString);
So, how should I setup the classpath?
Thanks for any help