I have a java project with multiple packages and classes. The main class which is called Driver.java is as follows:
package net.librec.tool.driver;
import net.librec.conf.Configuration;
import net.librec.job.RecommenderJob;
import net.librec.math.algorithm.Randoms;
import java.io.FileInputStream;
import java.util.Properties;
/**
* Created by Himan on 12/5/2016.
*/
public class Driver {
// Change this to load a different configuration file.
public static String CONFIG_FILE =
"conf/NBayes.properties";
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
String confFilePath = CONFIG_FILE;
Properties prop = new Properties();
prop.load(new FileInputStream(confFilePath));
for (String name : prop.stringPropertyNames()) {
conf.set(name, prop.getProperty(name));
}
Randoms.seed(20161205);
RecommenderJob job = new RecommenderJob(conf);
job.runJob();
System.out.print("Finished");
}
}
As you can see, in this class, I read the NBayes.properties. Here is the snapshot of my project structure:
I have created a jar file called librec.jar. However, when I run the program in command line using:
java -jar librec.jar
I get the following error:
java.io.FileNotFoundException: conf/NBayes.properties (No such file or directory)
What is the problem and what is the right way to run this program? Was making a jar file necessary?