简体   繁体   English

如何使用类ProcessBuilder在Netbeans中运行somethingHere.java?

[英]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. 我想运行NewCl.java,这是我当前软件包的一个类,但是我不知道该怎么做。我在Eclipse中进行了很多探索并找到了一种方法,但是我想在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*/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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