Results 1 to 20 of 24
- 08-21-2010, 02:04 PM #1
Member
- Join Date
- Aug 2010
- Posts
- 12
- Rep Power
- 0
JCreator and ACM NullPointerException - Help!
I got the acm.jar file from the jtf website, and I added it with the other jar files in JCreator. I copied this code from a textbook:
and I got this error:Java Code:import acm.graphics.*; import acm.program.*; public class testAcm extends GraphicsProgram { public void run() { add(new GLabel("hello, world",100,75)); } }
Exception in thread "main" java.lang.NullPointerException
at acm.program.Program.main(Program.java)
I have absolutely no Idea what that means. HELP SOMEBODY!Last edited by ajiboye.tayo; 08-22-2010 at 04:35 PM.
- 08-21-2010, 03:21 PM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Did you read the complete exception?
Post it here for more comment, otherwise how we can comment on it.
- 08-21-2010, 07:51 PM #3
Member
- Join Date
- Aug 2010
- Posts
- 12
- Rep Power
- 0
What do you mean by "did you read the complete exception"? I've posted the entire error message I got.
- 08-22-2010, 01:52 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Of course that's not the complete the error message. You must have set of text lines, stack trace. From that you can find the line of error occurred as well.
- 08-22-2010, 04:15 PM #5
Member
- Join Date
- Aug 2010
- Posts
- 12
- Rep Power
- 0
I think I'll just give you screenshots:


??? What say you?
- 08-22-2010, 04:27 PM #6
Get rid of your IDE and use the java command to execute the program.??? What say you?
- 08-22-2010, 04:31 PM #7
Member
- Join Date
- Aug 2010
- Posts
- 12
- Rep Power
- 0
@Norm
Thanks, but getting rid of my IDE isn't exactly an option right now.
- 08-22-2010, 04:33 PM #8
You should learn how to use the command prompt and the javac command. The IDE is hiding things.
Are you sure the import statements are correct? My copy of acm.jar doesn't have those packages.
- 08-22-2010, 06:15 PM #9
Member
- Join Date
- Aug 2010
- Posts
- 12
- Rep Power
- 0
@Norm
Could you write something simple for me using the copy of ACM you have? A simple Hello World will do...
- 08-22-2010, 06:25 PM #10
I used your program but had to change the import statements to what you now show.
Interesting that you changed the original source to cover up your error and don't tell anyone that you have done it.
Don't post code that does not compile and then tell us it does. It makes for a lot of wasted effort.
- 08-22-2010, 06:41 PM #11
Member
- Join Date
- Aug 2010
- Posts
- 12
- Rep Power
- 0
I had two different .java files, and mistakenly posted code from the wrong file.
I did edit the first post. But the code in the first post NOW still does not run. I typed it out directly from a textbook. I think the problem is somewhere at my end, and I just can't figure it out.
The code in the first post still does not work.
- 08-22-2010, 06:56 PM #12
Here is the code that works for me:
And here is the console when I execute it:Java Code:import acm.graphics.*; import acm.program.*; public class TestAcm extends GraphicsProgram { public void run() { add(new GLabel("hello, world",100,75)); } }
Running: "C:\Program Files\Java\j2re1.4.2_08\bin\java.exe" -cp D:\JavaDevelopment;.;acm.jar TestAcm
0 error(s)
- 08-22-2010, 07:06 PM #13
Member
- Join Date
- Aug 2010
- Posts
- 12
- Rep Power
- 0
@Norm
Your code (copied and pasted) gives me the same error I wrote in the first post, and included in the screenshots. I think the problem is somewhere at my end, but I can't seem to figure out what it is.
- 08-22-2010, 07:09 PM #14
Try running the code with the java command as I show in my post. Something like:
java -cp acm.jar;. TestAcm
Here's the console from when I run it:
D:\JavaDevelopment\Testing\ForumQuestions3\ACM_JTF >java -cp acm.jar;. TestAcm
D:\JavaDevelopment\Testing\ForumQuestions3\ACM_JTF >
- 08-22-2010, 07:18 PM #15
Member
- Join Date
- Aug 2010
- Posts
- 12
- Rep Power
- 0
I got the same error in the console...
- 08-22-2010, 07:35 PM #16
Please copy and paste here the FULL contents of the console.
- 08-22-2010, 07:47 PM #17
Member
- Join Date
- Aug 2010
- Posts
- 12
- Rep Power
- 0
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Tayo>cd Documents\JAVA
C:\Users\Tayo\Documents\JAVA>java -cp acm.jar;. testAcm
Exception in thread "main" java.lang.NullPointerException
at acm.program.Program.main(Program.java)
C:\Users\Tayo\Documents\JAVA>
- 08-22-2010, 08:05 PM #18
Ok, thanks.
No ideas.
Try downloading a new version of the acm.jar file.
My acm.jar file contains 91 files with the date: 8/25/2006 5:06 PM
- 08-22-2010, 08:28 PM #19
Member
- Join Date
- Aug 2010
- Posts
- 12
- Rep Power
- 0
Mine has 98 files.
2/16/2005. 5:16pm.
Could you please post a download link to yours? Apparently there's something wrong with mine, and even if not, I'd like to use yours.
Thanks a lot.
- 08-22-2010, 09:11 PM #20
Member
- Join Date
- Aug 2010
- Posts
- 12
- Rep Power
- 0
I downloaded another one from the same site (Lord knows what's wrong with them, even though it seems to have been updated only years ago). It's working now. Thanks a lot.
That didn't feel very good. But hey - I got my solution, right?I used your program but had to change the import statements to what you now show.
Interesting that you changed the original source to cover up your error and don't tell anyone that you have done it.
Don't post code that does not compile and then tell us it does. It makes for a lot of wasted effort.
Similar Threads
-
Ide(Jcreator) and jdk
By dangr in forum New To JavaReplies: 0Last Post: 01-12-2010, 08:02 AM -
jcreator
By arshesander in forum New To JavaReplies: 1Last Post: 08-03-2009, 11:31 AM -
About using jcreator
By yuchuang in forum JCreatorReplies: 4Last Post: 11-29-2008, 08:29 PM -
jcreator
By nikhil_solanki015 in forum JCreatorReplies: 2Last Post: 10-28-2008, 07:04 PM -
jar file in JCreator
By jadaleus in forum Advanced JavaReplies: 2Last Post: 10-22-2008, 11:07 PM


LinkBack URL
About LinkBacks

Bookmarks