Page 1 of 2 12 LastLast
Results 1 to 20 of 24
  1. #1
    ajiboye.tayo is offline Member
    Join Date
    Aug 2010
    Posts
    12
    Rep Power
    0

    Default 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:

    Java Code:
    import acm.graphics.*;
    import acm.program.*;
    
    public class testAcm extends GraphicsProgram
    {
    	public void run()
    	{
    		add(new GLabel("hello, world",100,75));
    	}
    }
    and I got this error:
    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.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Did you read the complete exception?

    Post it here for more comment, otherwise how we can comment on it.

  3. #3
    ajiboye.tayo is offline Member
    Join Date
    Aug 2010
    Posts
    12
    Rep Power
    0

    Default

    What do you mean by "did you read the complete exception"? I've posted the entire error message I got.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    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.

  5. #5
    ajiboye.tayo is offline Member
    Join Date
    Aug 2010
    Posts
    12
    Rep Power
    0

    Default

    I think I'll just give you screenshots:





    ??? What say you?

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,576
    Rep Power
    23

    Default

    ??? What say you?
    Get rid of your IDE and use the java command to execute the program.

  7. #7
    ajiboye.tayo is offline Member
    Join Date
    Aug 2010
    Posts
    12
    Rep Power
    0

    Default

    @Norm
    Thanks, but getting rid of my IDE isn't exactly an option right now.

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,576
    Rep Power
    23

    Default

    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.

  9. #9
    ajiboye.tayo is offline Member
    Join Date
    Aug 2010
    Posts
    12
    Rep Power
    0

    Default

    @Norm
    Could you write something simple for me using the copy of ACM you have? A simple Hello World will do...

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,576
    Rep Power
    23

    Default

    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.

  11. #11
    ajiboye.tayo is offline Member
    Join Date
    Aug 2010
    Posts
    12
    Rep Power
    0

    Default

    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.

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,576
    Rep Power
    23

    Default

    Here is the code that works for me:
    Java Code:
    import acm.graphics.*;
    import acm.program.*;
    
    public class TestAcm extends GraphicsProgram {
    	public void run() 	{
    		add(new GLabel("hello, world",100,75));
    	}
    }
    And here is the console when I execute it:
    Running: "C:\Program Files\Java\j2re1.4.2_08\bin\java.exe" -cp D:\JavaDevelopment;.;acm.jar TestAcm


    0 error(s)

  13. #13
    ajiboye.tayo is offline Member
    Join Date
    Aug 2010
    Posts
    12
    Rep Power
    0

    Default

    @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.

  14. #14
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,576
    Rep Power
    23

    Default

    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 >

  15. #15
    ajiboye.tayo is offline Member
    Join Date
    Aug 2010
    Posts
    12
    Rep Power
    0

    Default

    I got the same error in the console...

  16. #16
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,576
    Rep Power
    23

    Default

    Please copy and paste here the FULL contents of the console.

  17. #17
    ajiboye.tayo is offline Member
    Join Date
    Aug 2010
    Posts
    12
    Rep Power
    0

    Default

    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>

  18. #18
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,576
    Rep Power
    23

    Default

    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

  19. #19
    ajiboye.tayo is offline Member
    Join Date
    Aug 2010
    Posts
    12
    Rep Power
    0

    Default

    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.

  20. #20
    ajiboye.tayo is offline Member
    Join Date
    Aug 2010
    Posts
    12
    Rep Power
    0

    Default

    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.

    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.
    That didn't feel very good. But hey - I got my solution, right?

Page 1 of 2 12 LastLast

Similar Threads

  1. Ide(Jcreator) and jdk
    By dangr in forum New To Java
    Replies: 0
    Last Post: 01-12-2010, 08:02 AM
  2. jcreator
    By arshesander in forum New To Java
    Replies: 1
    Last Post: 08-03-2009, 11:31 AM
  3. About using jcreator
    By yuchuang in forum JCreator
    Replies: 4
    Last Post: 11-29-2008, 08:29 PM
  4. jcreator
    By nikhil_solanki015 in forum JCreator
    Replies: 2
    Last Post: 10-28-2008, 07:04 PM
  5. jar file in JCreator
    By jadaleus in forum Advanced Java
    Replies: 2
    Last Post: 10-22-2008, 11:07 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •