try{
Runtime.getRuntime().exec("cmd /c 执行的文件名");
}catch(Exception e){}

解决方案 »

  1.   

    这要用到jni了,涉及到具体的操作系统的问题
      

  2.   

    to ndb96(张华) :
    import java.io.*; class A {
      public static void main(String[] args){
        try {
          Runtime.getRuntime().exec("cmd /c F:\fpread32.exe");
        }
        catch (IOException ex) {
          System.out.println(ex);
        }
      }
    }不行哦
      

  3.   

    这是我写的一个访ping的小程序,原理就是调用window自带的ping.exe文件import java.net.*;
    import java.io.*;public class javaPing{
    public static void main(String[] args){
    String pingurl=null;
    if(args.length>0) { 
    pingurl=args[0];
    }
    else {
    pingurl="www.sina.com.cn";
    }
    pingurl="C:\\WINNT\\system32\\ping.exe "+pingurl;

    try 

    Process process = Runtime.getRuntime().exec ("pingurl"); 
    InputStreamReader ir=new InputStreamReader(process.getInputStream()); 
    LineNumberReader input = new LineNumberReader (ir); 
    String line; 
    while ((line = input.readLine ()) != null) 
    System.out.println(line); 

    catch (java.io.IOException e){ 
    System.err.println ("IOException " + e.getMessage()); 

    }
    }
      

  4.   

    Process p=Runtime.getRuntime().exec("notepad.exe");//启动记事本
    p.destroy();//退出记事本运行一个外部的程序直接将程序的路径传给Rutime的exec()方法即可。如果要运行一个dos命令,如设置时间,则不能直接使用exec("date ..."),可以通过动态创建一个.bat文件来执行该命令。
      

  5.   

    to  Lyongfei(雍菲)import java.io.*; class A {
      public static void main(String[] args){
        try {
          Runtime.getRuntime().exec(" F:/fpread32.exe");
        }
        catch (IOException ex) {
          System.out.println(ex);
        }
      }
    }
      

  6.   

    怎么调用远程的exe可执行文件呢?