简体   繁体   中英

java.awt.Desktop doesn't work

My computer's system is XP and when I open files like doc, txt or ppt,this code doesn't works.I already have office2007 , but desktop.open(file) can't open any file without erro Info. And some computers can work fine , why?

public boolean byDesktop(String path){  
      File file = new File(path);  
      if(file.isFile()){   
       Desktop desktop = Desktop.getDesktop();  
       try {  
        desktop.open(file);  
                } catch (IOException e) {  
                 System.out.println(e);  
                }  
       return true;  
      }else{  
       return false;  
      }  
     } 

You could check this link in stack overflow which discusses the same thing. But please do post the error so that we'll get a better understanding.

Facing problems with java.awt.Desktop in 64 bit JVM?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM