I am developing some code in Java but facing a problem with a NPE. It happens when I try to use a method in another class. Here is my code :
public class MyClass{
private Attributes attr = null;
public static void main(String [ ] args) throws ParseException, SAXException, IOException, ParserConfigurationException {
MyClass main = new MyClass();
Options options = main.parseCommandLine();
CommandLineParser parser = new BasicParser();
CommandLine cl = parser.parse(options, args);
main.configureAttributes(main);
}
private void configureAttributes(MyClass main, CommandLine cl) throws ParserConfigurationException, SAXException, IOException {
String[] attributes = cl.getOptionValues("a");
Integer tag = null;
for(int i = 0; i < attributes.length ; i++) {
String[] parts = attributes[i].split("=");
String tagName = parts[0];
String value = parts[1];
tag = Integer.parseInt(tagName,16);
this.attr.setString(tag, DICT.vrOf(tag), value);
}
}
}
But I am getting an NPE on the last line : this.attr.setString(tag, DICT.vrOf(tag), value);
I have all the right imports. It is a Maven project so I also added the dependency to my pom.xml.
Thanks a lot for your help !
V.