When I try to run this benchmark java8-lambda-benchmark.
Using the comand:
java -cp build/jar/LambdaMicrobench.jar lambdademo.LambdaAvgExtraParallel 50000
I get the following error:
lambdademo/load_employees.csv: Not found in jar
java.lang.NullPointerException
at lambdademo.EmployeeFile.loadEmployeeList(Unknown Source)
at lambdademo.LambdaAvgExtraParallel.main(Unknown Source)
Exception in thread "main" java.lang.NullPointerException
at lambdademo.EmployeeFile.loadEmployeeList(Unknown Source)
at lambdademo.LambdaAvgExtraParallel.main(Unknown Source
The file EmployeFile.java is the following:
public class EmployeeFile {
private static final String EMPLOYEE_FILE = "lambdademo/load_employees.csv";
public LinkedList<EmployeeRec> loadEmployeeList() {
LinkedList<EmployeeRec> employeeList = new LinkedList<>();
BufferedReader br = null;
try {
URL fileURL = getClass().getClassLoader().getResource(EMPLOYEE_FILE);
if (fileURL == null) {
System.out.println("resource is null");
}
InputStream in = fileURL.openStream();
br = new BufferedReader(new InputStreamReader(in));
} catch (Exception e) {
System.out.println(EMPLOYEE_FILE + ": Not found in jar");
e.printStackTrace();
}
try {
String line;
while ((line = br.readLine()) != null) {
String[] rec = null;
rec = line.split(",");
employeeList.add(new EmployeeRec(rec[0], rec[1], rec[2],
rec[3], rec[4], rec[5]));
}
} catch (IOException e) {
System.out.println("Error reading " + EMPLOYEE_FILE);
e.printStackTrace();
}
return employeeList;
}
Now I print the value of fileURL I get null.
The csv file is within the same folder as the sources for the project.
LambdaMicrobench.jar(e.g. using an IDE, maven, ant, ... )? Can you confirm that the.csvis at the right location inside the.jar(a.jaris a.zipfile, just use 7zip/unzip/tar or a similar tool to unpack its content)?ant -buildfile build.xml