为什么会出现文件不存在的错误?

huangapple go评论87阅读模式
英文:

Why am I getting file doesn't exist?

问题

我正尝试使用以下代码运行一个应用程序使用acquiadevdesktop

     Process p1 = Runtime.getRuntime().exec("C:\\Program Files (x86)\\DevDesktop\\AcquiaDevDesktop\\AcquiaDevDesktop2.exe");
            pb.start();
            Desktop.getDesktop().open(new File("AcquiaDevDesktop2"));
        } catch (IOException ex) {
            Logger.getLogger(HConnexion.class.getName()).log(Level.SEVERE, null, ex);
        }

但是我遇到了以下错误

    java.lang.IllegalArgumentException: 文件AcquiaDevDesktop2 不存在
	at java.desktop/java.awt.Desktop.checkFileValidation(Desktop.java:367)
	at java.desktop/java.awt.Desktop.open(Desktop.java:427)
	at DataBase.HConnexion.run_wamp(HConnexion.java:88)
	at DataBase.HConnexion.connectDb(HConnexion.java:35)
	at DataBase.DBcontrol.creer_piece(DBcontrol.java:105)
	at pdr.FrontController.initialize(FrontController.java:160)
	....

我可以尝试什么来解决这个问题
英文:

I am trying to run an app with acquiadevdesktop with this code:

 Process p1 = Runtime.getRuntime().exec("C:\\Program Files (x86)\\DevDesktop\\AcquiaDevDesktop\\AcquiaDevDesktop2.exe");
        pb.start();
        Desktop.getDesktop().open(new File("AcquiaDevDesktop2"));
    } catch (IOException ex) {
        Logger.getLogger(HConnexion.class.getName()).log(Level.SEVERE, null, ex);
    }

Yet I am getting this error:

java.lang.IllegalArgumentException: The file: AcquiaDevDesktop2 doesn't exist.
at java.desktop/java.awt.Desktop.checkFileValidation(Desktop.java:367)
at java.desktop/java.awt.Desktop.open(Desktop.java:427)
at DataBase.HConnexion.run_wamp(HConnexion.java:88)
at DataBase.HConnexion.connectDb(HConnexion.java:35)
at DataBase.DBcontrol.creer_piece(DBcontrol.java:105)
at pdr.FrontController.initialize(FrontController.java:160)
....

What can I try to fix it?

答案1

得分: 1

确保添加文件类型,因为new File()无法假设文件类型。

例如,如果是文本文件,应为:new File("AcquiaDevDesktop2.txt"));

英文:

Make sure to add the filetype, because new File() can't assume what type it is.

For example, if it's a text file, it should be: new File("AcquiaDevDesktop2.txt"));

huangapple
  • 本文由 发表于 2020年9月22日 01:18:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/63997100.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定