简体   繁体   中英

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

I want to run the NewCl.java that is a class of my current package, but i cant figure it out how to do that.I serch a lot and find a way in Eclipse but i want to do it in Netbeans. What is wrong with this code?

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

OK, i just find the solution. If someone needs it this is the solution:

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*/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM