Under the WINDOW7 System experiment (Linux under Path format is not the same as under Windows) Eclipse uses Runtime.getruntime (). exec Start 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.
Today in Eclipse wrote the use of Runtime.getruntime (). EXEC ("Java MyTest"); To start a new Java program, but could not start the MyTest class.
1. This program can be fully functional in CMD. So I copied the mytest.class (except the package name) to the root of the project and suddenly found that the MyTest program started
The
I came to the conclusion that when using Runtime.getruntime (). exec to start other Java programs, the Java Virtual machine starts looking for this class at the root of the project, and this class actually exists under the bin directory. At this time, as long as the command to add Classpath settings information can be, plus the package name.
The last modified code is as follows:
2. Runtime.getruntime (). EXEC ("Java-classpath h:\\workspace\\javawork\\bin cn.itcast.io.MyTest");
Or
3.runtime.getruntime (). EXEC ("Java-classpath./bin cn.itcast.io.MyTest"); . Represents the current directory.
Or
4.runtime.getruntime (). EXEC ("Java-classpath bin Cn.itcast.io.MyTest");
The program runs normally!
Original: http://blog.sina.com.cn/s/blog_6b96eae10100ok01.html
Under Eclipse, use Runtime.getruntime (). exec Start ja