0

This question has been asked before but with no real answer.

I wan't to start a Java Progam form another Java Program. In my case I wan't to start the same program(2) and then exit the original program(1) while the clone is still open.

Unfortunatly I can't get this to work with ProcessBuilder

ProcessBuilder processBuilder = new ProcessBuilder("java","Programm");

Process process = processBuilder.start();

No error message, nothing happens.

I also can't run the program from the CMD in windows. javac shows several errors during compilation:

symbol not found, ...

I can start the program normally from Eclipse.

3
  • symbol not found maybe you forgot to set classpath? Especially when it works with eclipse. Also, it would help if you could provide more information and the concrete call of your ProcessBuilder Commented Feb 16, 2012 at 13:57
  • If you run javac to compile it, you need to add all needed jars to the classpath. See the javadoc for javac. (javac -classpath ...) Commented Feb 16, 2012 at 13:58
  • "I wan't to start the same program(2) and then exit the original program" Why, what are you trying to achieve by doing that? Commented Feb 16, 2012 at 14:08

1 Answer 1

3

You probably aren't seeing the errors from your Process because they are sent to its own error stream. You can access the error stream using process.getErrorStream().

I suspect the problem is that your classpath isn't properly set when invoking the java executable and it is failing to find your class or its dependencies, but it is hard to tell without seeing the error.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.