Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Runtime Error in Program for Unknown Reasons  RSS feed

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I typed this up myself from Head First Java. I keep getting a NullPointerException that says the following:

Exception in thread "main" java.lang.NullPointerException
at QuizCardPlayer.go(QuizCardPlayer.java:27)
at QuizCardPlayer.main(QuizCardPlayer.java:19)

I didn't see anything blatently wrong with the code I had written, and the problem appeared to be in my first two methods, but it starts up the same way as some other programs of mine that work fine. Here is the code, cut and pasted fresh from jGrasp.



If someone could scan this over or if they know that I made some stupid mistake (I haven't done GUI in awhile, I'm still getting back into the swing of things, no pun intended) I would be immensley thankful.
[ June 04, 2008: Message edited by: Rob Prime ]
 
author and iconoclast
Sheriff
Posts: 24220
40
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The top line from the stack trace in the error message

at QuizCardPlayer.go(QuizCardPlayer.java:27)

means that the error happens at line 27 of this file. Use your editor to figure out what line that is. A NullPointerException on a particular line always means that something to the left of a dot ('.') or left-brace ('[') is null. Find out what variable on that line might be null, then try to figure out where its value should have been set, and you'll have solved the problem.
 
Jacob Steingart
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aha! I was stupid and forgot to declare the JTextArea... now it works!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!