Win 下面可以用
start *.txt
start *.doc
等等

解决方案 »

  1.   

    thanks, 那么在linux上呢? 我的程序需要跨平台。
      

  2.   

    windows  是 aaa.exe   aaa.txt
    linux 是 ./aaa.exe  ./aaa.txt配上
    try{
    Runtime.getRuntime().exec("cmd /c 执行的文件名");
    }catch(Exception e){}98/me 是 command
    nt/2000/xp 是 cmd
    linux 是 shall (←大概拼错了)
      

  3.   

    to (一品狐) : 我指的是执行各类文件,包括那些非可执行文件。比如说, .doc 文件会默认用 office 打开
             .txt 文件会默认用 vi 打开。 telenths(_非法操作_) 网友说的 start 命令在windows系统上可以实现我的想法,非常感谢。 linux上我还不知道怎么处理。希望各位指教。
      

  4.   

    Runtime.getRuntime().exec("执行的文件地址(绝对路径)");也可以
      

  5.   

    to NextTimezyp(跋涉者) : 您确定么? 我刚刚在windows xp上用你的方法怎么不行?您指的是在linux上么?
      

  6.   

    Runtime.getRuntime().exec()是可以的
      

  7.   

    Sorry in english, but i v 2If it's only in win, start cmd can do that job.If in a variety of environment, that's just like the problem you faced in windows, when you double click on the file ends with an unknown extension name, such as abc.xyz, the windows will ask you to select from a list of programs to be used as the default executable program in future use. When the program is not on the list, you can secelt form a file chooser. The selection will be stored in the registery book.So you may solve this problem like this.First determine whether the environment is win(System.getProperty("os.name").startsWith("Windows")). If true, use start. Otherwise, open a JFileChooser to let the user himself to choose one, and save the absolute path of the selection for this extension type, such as .xyz in this example, in a file, and next time when the user wanna open a file end with .xyz, read that file and call that program to open it.
    Really very sorry in so many english words.
    This computer doesn't have any pinyin or 5b
      

  8.   

    to shine333(shine): thanks a lot. 我想你的方法是可行的。过一会儿,我再试试上面提到的一些方法就结贴。