0
\$\begingroup\$

What's my problem:

It says there is a null pointer exception in my desktop launcher class even though I haven't really touched it other than add a title and change the width & height. The weird thing is I haven't touched it and I've called my program before.

Error in Eclipse

Desktop Launcher Code:

    package com.kymedgames.poopman.desktop;

    import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
    import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
    import com.kymedgames.poopman.Game;

    public class DesktopLauncher {
public static void main (String[] arg) {
    LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
        config.title = "Poopman Adventures";
        config.width = 800;
        config.height = 600;
    new LwjglApplication(new Game(), config);
}
}

My Application Listener class in my core package is named Game.

What I'm trying to accomplish:

Run my application on desktop. (Which I have done before.)

How I'm trying to accomplish it:

By pressing the run button on Eclipse and not touching my desktop launcher other than add a title, width & height.

What I need help with:

Fix this randomly occurring error.

Am I a noob?

Kind of.

\$\endgroup\$
1
\$\begingroup\$

You have (or one of your dependencies has) a static constructor that is failing, and it's failing because it tries to dereference something that is null.

You can see where this is happening by using the Eclipse feature Add Java Exception Breakpoint. This is a way of setting a breakpoint that is hit whenever an exception of a specific type is thrown.

Add an exception breakpoint for NullPointerException and it should show you where in the code something is null in a static constructor.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Judging by the line number of DesktopLauncher, the offending static initializer is in the Game class. Check the static { } block in the Game class \$\endgroup\$ – spectacularbob Feb 18 '16 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.