Exception in thread "AWT-EventQueue-0" java.lang.NullPointerExeption

Trying to read a .xml file, and return the findings. My app already writes to the .xml file. The error I get is 'Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException.

The code in my action performed method calls the ReadEntry method:

elseif( e.getSource( ) == ReminderViewSearch ){

ReadEntry( doc.getDocumentElement( ) );

}

The ReadEntry method is this:publicboolean ReadEntry( Node node ){

String a = ReminderViewYearTxt.getText( );

String b = ReminderViewMonthTxt.getText( );

String c = ReminderViewDayTxt.getText( );

node = getYear( node );

if( node ==null )returnfalse;

node = getMonth( node );

if( node ==null )returnfalse;

node = getDay( node );

if( node ==null )returnfalse;

node = node.getFirstChild( );

while( node !=null ){

//ReminderViewResult.setText( node.getNodeValue( ).trim( ) );

//ReminderViewResult.setText( node.getAttributes( ).item( 0 ).getNodeValue( ) );

System.out.println(node.getNodeValue().trim());

node = node.getNextSibling( );

}

returntrue;

}

And the GetYear method looks like this:private Node getYear( Node node ){

node = node.getFirstChild( );

while( node !=null ){

if( node.getNodeName( ).equals("Year" ) && ( node.getAttributes( ).item( 0 ).getNodeValue( ).equals( a ) ) )

return node;

node = node.getNextSibling( );

}

returnnull;

}

The GetMonth and GetDay methods are the same as the GetYear method, just with different variables.

Any help would be much appreciated. Cheers.

[2913 byte] By [Redstaara] at [2007-11-27 6:51:24]
# 1

> Trying to read a .xml file, and return the findings.

> My app already writes to the .xml file. The error I

> get is 'Exception in thread "AWT-EventQueue-0"

> java.lang.NullPointerException.

And with that exception you should be getting a stack trace, which would show you exactly which class, method, and line of code it occurred on. That is needed for further assistance.

warnerjaa at 2007-7-12 18:25:48 > top of Java-index,Java Essentials,New To Java...
# 2
It says the error is at CalendarAssignment.actionPerformed(CalendarAssignment.java:640)Line 640 is: ReadEntry( doc.getDocumentElement( ) );Cheers
Redstaara at 2007-7-12 18:25:48 > top of Java-index,Java Essentials,New To Java...
# 3
> It says the error is at> CalendarAssignment.actionPerformed(CalendarAssignment.> java:640)> > Line 640 is: ReadEntry( doc.getDocumentElement(> ) );> > CheersThen doc == null at that point.
warnerjaa at 2007-7-12 18:25:48 > top of Java-index,Java Essentials,New To Java...
# 4
lol I feel dead stupid!!!! lolYeah, it's because I didn't define doc in CalendarAssignment. It were inside the method for creating an entry.How the bloody hell did I not notice that?!Cheers for the help anyway!!!!!!
Redstaara at 2007-7-12 18:25:48 > top of Java-index,Java Essentials,New To Java...
# 5
One more thing guys, does anybody know how to open a notepad document using java?I just wanna have a button that will open an external document.Cheers.
Redstaara at 2007-7-12 18:25:48 > top of Java-index,Java Essentials,New To Java...
# 6
Runtime.getRuntime().exec("notepad [filename]");
SomeoneElsea at 2007-7-12 18:25:48 > top of Java-index,Java Essentials,New To Java...
# 7
When you put the filename in, I'm guessing that you have to put the full filepath?If so, how can I make java locate the drive and directory that CalendarAssignment.java is in on any machine?
Redstaara at 2007-7-12 18:25:48 > top of Java-index,Java Essentials,New To Java...