window7系统下实验(linux下路径格式和windows下不一样) Eclipse下使用Runtime.getRuntime().exec启动ja
RunTime.getRuntime().exec("java My_Program");System.exit(0); which would start a whole new JVM running your program, and then kill the original. Not exactly pretty or efficient, but it would restart it.
今天在Eclipse中写了用到 Runtime.getRuntime().exec("java MyTest"); 来启动一个新的java程序,无奈却无法启动MyTest类。
了!
最后修改代码如下:
2. Runtime.getRuntime().exec("java -classpath H:\\workspace\\javawork\\bin cn.itcast.io.MyTest");
或者
或者
4.Runtime.getRuntime().exec("java -classpath bin cn.itcast.io.MyTest");
程序正常运行!
原文: