Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Exception in thread "main" java.lang.NullPointerException

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Exception in thread "main" java.lang.NullPointerException

    Hello, I really hopeless and I feel like this is my last chance to fix that, before I will have to send this to my teacher.
    I'm getting this error:
    Exception in thread "main" java.lang.NullPointerException
    at ui.PanelBatohu.<init>(PanelBatohu.java:33)
    at ui.Gui.init(Gui.java:107)
    at ui.Gui.<init>(Gui.java:68)
    at main.Start.main(Start.java:25)

    Legend: Doing graphic interface for this one little java game.
    Batoh= Bag(container in game)
    zaregistruj pozorovatele(register observer)


    first error line is:

    [30] public PanelBatohu(Batoh batoh) {
    [31] super();
    [32] this.batoh = batoh;
    [33] batoh.zaregistrujPozorovatele(this);
    [34] this.aktualizuj(batoh);
    [35]
    [36] this.setBorder(BorderFactory.createTitledBorder("V ěci v batohu:"));
    [37] this.setVisible(true);
    }


    second error line is:


    [107]panelBatohu = new PanelBatohu(hra.getBatoh());
    [108] hlavniOknoFrame.add(panelBatohu, BorderLayout.WEST);[LIST=1]


    third error line:

    [65]public Gui(Hra hra) {
    [66] this.hra = hra;
    [67] initMenu();
    [68] init();

    fourth error line:


    [23]public static void main(String[] args) {
    [24] if (args.length == 0) {
    [25] Gui grafika = new Gui(new Hra());


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Exception in thread "main" java.lang.NullPointerException

    Look at the line throwing the NPE. You are dereferencing something that is null on that line. What is it? You can use a debugger or some print statements to figure it out.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Exception in thread "main" java.lang.NullPointerException problem.......
    By Adam802 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: September 20th, 2012, 02:23 AM
  2. Exception in thread "main" java.lang.NullPointerException
    By linux.sys in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 22nd, 2012, 06:01 AM
  3. Replies: 3
    Last Post: December 7th, 2011, 02:03 AM
  4. Exception in thread "main" java.lang.NullPointerException
    By isun in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 28th, 2011, 09:22 AM
  5. Exception in thread "main" java.lang.NullPointerException
    By MryJaho in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 4th, 2011, 05:36 PM