简体   繁体   English

当我从终端运行Java程序时缺少属性文件

[英]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.

相关问题 当我从终端手动运行Java程序时,它运行正常,但是当我从Eclipse运行时,它却无法运行 - When I am running java program manually from terminal it is working fine but it is not working when i am running from eclipse 打开终端失败:缺少或不合适的终端:从 Java 程序运行 shell 脚本时未知 - open terminal failed: missing or unsuitable terminal: unknown when running shell script from Java program 从终端运行Java程序 - Running java program from terminal 为什么在终端和 Java 中运行 curl 命令时得到不同的结果? - Why am I obtaining different results when running curl command from Terminal and in Java? 当我从Netbeans运行JFrame程序时,印地语字体是可见的,但运行.jar文件时,则看不见 - Hindi font is visible when I am running JFrame program from Netbeans but not visible when running .jar file 使用终端从Mac文件夹运行Java程序 - Running Java Program from Folder Mac with Terminal 程序未针对Java进行编译我缺少什么 - Program is not compiling for Java what am I Missing 为什么从文件重定向输入而不是为Java程序手动输入时出现异常? - Why am I getting an exception when redirecting input from file, but not manual input for a Java program? 从终端运行代码时会创建文本文件,但在Java中运行时不会创建文本文件 - Text file is created when running code from the terminal, but not when running it in Java 从终端运行Java项目时没有此类文件 - No such file while running a java project from Terminal
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM