I did search to find a solutions for this issue but I could not get proper ansewer.
My problem is I have a NetBeans project which has following folder structure.
MyProject
Source Packages
---------------
controller
.
.
.
.
databaseconfiguration
application
Application.java
source
DbConfig.txt
DbConfig.txt is in source . Application.java is in application
in Application.java I do read DbConfig.txt. as following code
String path = ClassLoader.getSystemResource("source/DbConfig.txt").getPath();
File f = new File(path);
fr = new FileReader(f);
BufferedReader br = new BufferedReader(fr);
while (br.ready()) {
String line = br.readLine();
if(line.isEmpty()){
continue;
}
else{
JOptionPane.showConfirmDialog(null,line);
}
}
this is working fine when I run in Netbeans IDE.
But after building , when I try to run this using MyProject.jar it gives null pointer exception (java -jar MyProject.jar in cmd)
Please tell me how to sort out this problem. Thanks in advance.