java - File not found when running jar from command line of a NetBeans project -
i wrote java application using netbeans. reads text file project's root directory. when run jar file command line can't find required file.
string inputfile = "input.txt"; properties prop = new properties(); string targetformat = null; try { inputstream input = new fileinputstream("book-info-converter.properties"); prop.load(input); targetformat = prop.getproperty("targetformat"); } catch(ioexception ex){ system.out.println("file not found"); } how solve problem? put file application can find when running jar command line?
place book-info-converter.properties in src folder (it's better in resources if have). can load resource stream like
inputstream input = yourclass.class.getresourceasstream("/book-info-converter.properties");
Comments
Post a Comment