aspose file tools*
The moose likes Java in General and the fly likes Why does this crash Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Why does this crash" Watch "Why does this crash" New topic
Author

Why does this crash

Jeffrey Chu
Greenhorn

Joined: May 01, 2005
Posts: 10

i get a java.lang.nullpointerexception


I'm sorry if i break any rules, im new, please bear with me while I learn the rules.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Please post the EXACT error message. It contains a LOT of information that can help us help you track down the problem.

Layne


Java API Documentation
The Java Tutorial
Jeffrey Chu
Greenhorn

Joined: May 01, 2005
Posts: 10


sry about that im new here
[ May 01, 2005: Message edited by: Jeffrey Chu ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34



Typo. Should be "word2 = ". Since word2 is null when you call add(), you get a NullPointerException. That stack trace says the error happens at line 28 in your applet; so you look at line 28, and figure out what's wrong.
[ May 01, 2005: Message edited by: Ernest Friedman-Hill ]

[Jess in Action][AskingGoodQuestions]
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
No problem. Let's analyze what the error message says.

The first line indicates that your program threw an NullPointerException (which you obviously already knew). The next line starts what is called the "call stack". This is the chain of method calls that lead up to the exception. The first line tells you that this exception was thrown from java.awt.Container.addImpl() which is in the standard Java API. Notice that it also indicates the source file name and line number. If you want to, you can look at the source code that comes with the JDK. At this point, we probably just want to find the problem with your own code, so let's continue. The next line tells you that Container.addImpl() was called from Container.add() which is again a method from the Java API. The third line finally gives us a method in your own code: Pretty.init(). Container.add() was called on line 28 in Pretty.java. So now what is line 28?

Well, it looks like I took to long to finish typing my response. EFH has already given you some more information. However, I thought I'd still submit my post so that you can understand the information that the error message gives you and hopefully track down these kinds of errors on your own next time.

Keep Coding!

Layne
[ May 01, 2005: Message edited by: Layne Lund ]
Jeffrey Chu
Greenhorn

Joined: May 01, 2005
Posts: 10
o wow... now i feel stupid... thanks guys for your input
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why does this crash