[英]Missing properties file when i am running a java program from terminal
To run my application i use the command 要运行我的应用程序,请使用以下命令
java -jar "/home/stelios/NetBeansProjects/Askisi1/dist/Askisi1.jar"
However while i have the config.properties file in this directory 但是尽管我在此目录中有config.properties文件
"/home/stelios/NetbeansProjects/Askisi1/config.properties"
it runs normally in netbeans but when i try to run it from the terminal it produces this error 它在netbeans中正常运行,但是当我尝试从终端运行它时会产生此错误
java.io.FileNotFoundException: config.properties (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:97)
at askisi1.MainThread.main(MainThread.java:237)
What should be the correct location for my properties file? 我的属性文件的正确位置应该在哪里?
When you run you program from terminal your current folder becomes default folder for java app. 从终端运行程序时,当前文件夹将成为Java应用程序的默认文件夹。 So if you want your app to see
config.properties
you either need it to copy to current folder to go to /home/stelios/NetbeansProjects/Askisi1/
and run app from there. 因此,如果您希望您的应用查看
config.properties
,则需要将其复制到当前文件夹以转到/home/stelios/NetbeansProjects/Askisi1/
并从那里运行应用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.