java runtime errors

Using the Java SDK with TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
ezchucky
Posts: 4
Joined: Sun Nov 23, 2003 12:50 am
Location: new york city

java runtime errors

Post by ezchucky »

I am having problems running my java program. It compiles with no errors, but when I attempt to run it, I get runtime errors. The question is the line numbers it points to are not in my program. I have only 800 lines, but the error is line 1121. I assume this is due to the imports. How can I see the bad line of code ? I am using TextPad and SDK 1.4.2_01..
Thanks
Charlie
User avatar
talleyrand
Posts: 624
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

While this is a question probably better suited to a true Java forum, if Keith has no objections, let's see what's going on in your code. What's the specific error being produced?
I choose to fight with a sack of angry cats.
ezchucky
Posts: 4
Joined: Sun Nov 23, 2003 12:50 am
Location: new york city

Run Time errors

Post by ezchucky »

The error is NullPointerException at JMenu.createActionComponent (JMenu.java:647) at JMenu.add(JMenu.java:625) at <init>(java:177) at main(java:468)
User avatar
talleyrand
Posts: 624
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Re: Run Time errors

Post by talleyrand »

ezchucky wrote:The error is NullPointerException at JMenu.createActionComponent (JMenu.java:647) at JMenu.add(JMenu.java:625) at <init>(java:177) at main(java:468)
Granted, I am tired but I fail to see line 1121 mentioned in your error message. If you're being duplicitous, don't. People on here are usually pretty receptive to answer problems when they can (remember we don't get paid for doing this. We're just people who really enjoy TP and like to spread the word and occasionally pick up some wicked tips and tricks)

Having said that, it appears that in your main function (public static void main(String argv)) at line 468 you are attempting to add an object to an instance of JMenu that is null. I don't do GUIs for a very good reason so I can't make a guess as to what you are doing wrong but look at that line and the preceding lines dealing with the instance of JMenu and whatever object/params you are passing to to it. Make sure those values (toString() is handy for this) appear to be what you expected.
I choose to fight with a sack of angry cats.
ezchucky
Posts: 4
Joined: Sun Nov 23, 2003 12:50 am
Location: new york city

Run Time errors

Post by ezchucky »

Sorry, those numbers were just an example. Actually my program is 481 lines. But the line numbers for the error messages are correct...

I am very grateful for the help...

Thanks !!!!!!!!!!!!!!!11

Charlie
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

And now you expect that we correct your code without knowing it?
ezchucky
Posts: 4
Joined: Sun Nov 23, 2003 12:50 am
Location: new york city

Post by ezchucky »

Hey guys, cut me some slack ! I was not asking for anyone to debug my code. All I was looking for was an answer as to how I could find out what line numer 647 was. Is there not a source listing option that shows the code after the imports with line numbers ?
User avatar
talleyrand
Posts: 624
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

If you are looking to see what the code looks like for an imported class, you will be out of luck unless you wrote it, have the source or have a decompiler handy (if it's standard Swing classes it won't decompile and you can probably assume it's coding correctly).

If you are looking to turn on line numbering in TP, View -> Line Numbers Control-G will give you the option of jumping to whatever line (or column/page/Byte/Bookmark) you'd like.
I choose to fight with a sack of angry cats.
Post Reply