import java.lang.*; public class TestExec{ public static void main(String args[]) { try{ Process pro = Runtime.getRuntime().exec("explorer http://localhost"); } catch(Exception ex){ System.out.println("error"); } } }这是打开浏览器,访问本机!
T:draco2002(Draco—五月的风~青岛!) 我现在想问能不能通过Runtime.getRuntime().exec()运行其它的应用程序啊?比如说vb等. Process pro = Runtime.getRuntime().exec("explorer http://localhost");
import java.lang.*; public class TestExec{ public static void main(String args[]) { try{ Process pro = Runtime.getRuntime().exec("C:\\Program Files\\JBuilder9\\bin\\JBuilderW.exe TestExec.java"); } catch(Exception ex){ System.out.println("error"); } } }上面的程序就是通过调用jb9直接打开TestExec.java文件!!!!
TO:draco2002(Draco—五月的风~青岛!) Process pro = rt.exec("D:\\Program Files\\Microsoft Visual Studio\\VB98\\VB6.EXE start BFormTest.vbp"); BFormTest.vbp为vb项目,(要不要将它放入我的java application中?) 我用上面的方法,但还是不行?请指教!!!!
TO:draco2002(Draco—五月的风~青岛!) Process pro = rt.exec("D:\\Program Files\\Microsoft Visual Studio\\VB98\\VB6.EXE VBFormTest.vbp"); 这样一来的话,知识启动该项目,该项目并没有执行啊!!我想启动并执行该项目请问能不能实现啊??
public static void main(String[] arg){
try{
Process p = Runtime.getRuntime().exec("notepad.exe ");
Thread.sleep(5000);
p.destroy();
}
catch(InterruptedException e){
}
catch(IOException e1){
}
看对你有帮助不?
但是我试了一下.不行,哪为高手做过啊,请多多帮忙!!!!!
public class TestExec{
public static void main(String args[])
{
try{
Process pro = Runtime.getRuntime().exec("explorer http://localhost");
}
catch(Exception ex){
System.out.println("error");
}
}
}这是打开浏览器,访问本机!
我现在想问能不能通过Runtime.getRuntime().exec()运行其它的应用程序啊?比如说vb等.
Process pro = Runtime.getRuntime().exec("explorer http://localhost");
就这个意思!!
我估计你说的是调用可执行文件,则使用:cmd /c start c:\路径\文件名 即可.
我的意思是调用编译好的vb程序?(想问一下getRuntime().exec()是不是只能启动.exe文件啊?)
Process pro = Runtime.getRuntime().exec("c:\路径\vb启动程序 start 项目名称");
public class TestExec{
public static void main(String args[])
{
try{
Process pro = Runtime.getRuntime().exec("C:\\Program Files\\JBuilder9\\bin\\JBuilderW.exe TestExec.java");
}
catch(Exception ex){
System.out.println("error");
}
}
}上面的程序就是通过调用jb9直接打开TestExec.java文件!!!!
Process pro = rt.exec("D:\\Program Files\\Microsoft Visual Studio\\VB98\\VB6.EXE start BFormTest.vbp");
BFormTest.vbp为vb项目,(要不要将它放入我的java application中?)
我用上面的方法,但还是不行?请指教!!!!
Process pro = rt.exec("D:\\Program Files\\Microsoft Visual Studio\\VB98\\VB6.EXE VBFormTest.vbp");
这样一来的话,知识启动该项目,该项目并没有执行啊!!我想启动并执行该项目请问能不能实现啊??