aspose file tools*
The moose likes Beginning Java and the fly likes Exception in thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exception in thread "main" java.lang.NullPointerException" Watch "Exception in thread "main" java.lang.NullPointerException" New topic
Author

Exception in thread "main" java.lang.NullPointerException

Andrew Sepulveda
Greenhorn

Joined: Oct 02, 2011
Posts: 10
the user interface class



the main class




I am not sure why I am getting this...



I am running on eclipse and it does not show in the code itself that it is an error, only in the console.
Anybody realize why this is happening?
Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
One of the great things about Java is that the error messages usually give you a good idea of what's going on; just read them carefully.

In your case it says "NullPointerException", and "failure.java:22", meaning line 22 in that class.

line 22 contains "item.addItemListener..."; you should be wondering if item has been instantiated.

And you can look back and see that, although you declared item to be a JComboBox, you never instantiated a JComboBox to put in it.

rc
Andrew Sepulveda
Greenhorn

Joined: Oct 02, 2011
Posts: 10
thank you. the program now works functionally.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception in thread "main" java.lang.NullPointerException