wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes getting an error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "getting an error "Exception in thread "AWT-EventQueue-0" java.lang.NullPointerExcept"" Watch "getting an error "Exception in thread "AWT-EventQueue-0" java.lang.NullPointerExcept"" New topic
Author

getting an error "Exception in thread "AWT-EventQueue-0" java.lang.NullPointerExcept"

abhijeet shrivastava
Greenhorn

Joined: Jan 05, 2007
Posts: 10
Hi ranchers,

I am getting an error while executing a swing application.on the click of a button,I am capturing the inputs passed by an user and passing them to my another programme,but i am getting the following error

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

code for actionperformed method is as follows.

public void actionPerformed(ActionEvent e)
{
if ("submit".equals(e.getActionCommand()))
{
variables = new HashMap(); // declared the swing class.
variables.put("ServiceURL",url.getText());
variables.put("Value",ssn.getText());
variables.put("CallingAppRole",prtcpnt_id.getText());
variables.put("Life Event Code",life_evnt_cd.getText());
variables.put("Envoirnment",envoirnment.getSelectedItem());
WSTestHarness testHarness = new WSTestHarness();
testHarness.setgui_swing(variables);
testHarness.executeTestSession();
}
}





Thanks in advance.

Regards,
Abhijeet Shrivastava
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Take a look at the full stack trace. It should tell you in which line the NPE occurs, which should make it rather obvious which variable is null.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
everytime i got one of those errors, it was because i was trying to
compare or modify a variable without actually declaring it first.

like for instance:



you'll get a null pointer exception, not in the event queue, because
you didnt call it in the actionlistener or mouse/key.

but it is a similar incident.

post the whole code, and I could try to help you further.

Justin


You down with OOP? Yeah you know me!
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Justin Fox:
everytime i got one of those errors, it was because i was trying to
compare or modify a variable without actually declaring it first.


Just to get the terminology straight, in your example code the theField variable *is* declared, but not *initialized*.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting an error "Exception in thread "AWT-EventQueue-0" java.lang.NullPointerExcept"