如何使用 Class ProcessBuilder 与 Netbeans 一起运行 somethingHere.java?

How to run a somethingHere.java with Netbeans using the Class ProcessBuilder?

我想运行 NewCl.java,它是我当前包的 class,但我不知道如何进行 that.I 大量搜索并找到方法Eclipse,但我想在 Netbeans 中进行。这段代码有什么问题?

String [] command = {"java","-cp",".\build\classes","NewCl",String.valueOf(num2),String.valueOf(num1)}; ProcessBuilder pb = new ProcessBuilder(command); System.out.println(); Process p = null;

好的,我刚刚找到解决方案。如果有人需要,这是解决方案:

String [] command = {"java", "-cp", System.getProperty("java.class.path"), "testing.NewCl", /*packagename + class*/ String.valueOf(num2),/*Useless for you*/ String.valueOf(num1)}; /*Useless for you*/