• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AWT

 
Manoj Syoran
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir When I run this code I get a NullPointerException.Please help me in finding the reason for this error in my code.


 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to state exactly where the NPE is happening. Paste in the exactly, complete error message, including the stack trace, and make it clear which line is causing it.
 
Tim Moores
Bartender
Posts: 2792
38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never do this:

catch(Exception ex)
{
///////////////
}

At the very least print a message to where you will see it. For example, if there's a problem in line 134 or 135, the con or st variables will be null, yet you won't know anything about it.
 
Manoj Syoran
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir I am sending image of exception on the commandline
 
Matthew Brown
Bartender
Posts: 4567
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something isn't right with that image. Just tell us which line of the code you've posted the error is occurring on (you'll have to convert the file line number it's reporting to you to the line of code that you've posted, if they aren't exactly the same).
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Manoj Syoran wrote:Sir I am sending image of exception on the commandline


PostTextNotScreenshots (<-- It's a link. Click it.)

And of course we can't see your image. Did you notice that it is rooted at your C: drive? You wouldn't expect the entire world to be able to get to your computer just via "C:", would you?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can capture the text in a Command Prompt window as simple text - screen shots are a waste of bandwidth and wont show the entire stack trace.

1. right click on the upper left corner to get a menu
2. pick the Edit -> select all option - selected text will be highlighted
3. press enter - text will be on clipboard
 
Manoj Syoran
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir, Here is the error code.
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Manoj Syoran wrote:

In your actionPerformed method, on line 217, you are adding something that's null to a container. I see only one line that could be the cause, p8.add(lbl[i]);. This would mean that lbl[i] is null, and that can only be the case if your database query returned 0 results.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic