Beginner Tutorial 5: Hello Input - ERROR: HelloInput is not abstract and does not override abstract method simpleInitApp()

Good afternoon,

I’m a Information & Multimedia Technologies student with beginner-intermediate Java knowledge. I just started learning the JMonkeyEngine.

While I was following the Tutorial 5 (Hello Input), I encountered the following errors:

HelloInput is not abstract and does not override abstract method simpleInitApp() in SimpleApplication
public class HelloInput

method does not override or implement a method from a supertype
@Override

I double checked the tutorial code with mine, the only variation is some variable names.

package jme3test.helloworld;

import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.math.ColorRGBA;
import com.jme3.input.KeyInput;
import com.jme3.input.MouseInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.AnalogListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.input.controls.MouseButtonTrigger;

public class HelloInput 
    extends SimpleApplication 
{
    public static void main (String[] argv)
    {
        HelloInput app = new HelloInput();
        app.start();
    }
    
    protected Geometry jugador;
    Boolean isRunning=true;
    
    @Override
    public void SimpleInitApp()
    {
        Box caja = new Box (1,1,1);
        jugador = new Geometry ("Jugador", caja);
        Material material = new Material(assetManager,
                "Common/MatDefs/Misc/Unshaded.j3md");
        material.setColor("Color", ColorRGBA.Blue);
        jugador.setMaterial(material);
        rootNode.attachChild(jugador);
        initKeys();
    }
    
    private void initKeys()
    {
        inputManager.addMapping("Pause", new KeyTrigger(KeyInput.KEY_P));
        inputManager.addMapping("Left", new KeyTrigger(KeyInput.KEY_J));
        inputManager.addMapping("Right", new KeyTrigger(KeyInput.KEY_K));
        inputManager.addMapping("Rotate", new KeyTrigger(KeyInput.KEY_SPACE),
                                new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
        
        inputManager.addListener(actionListener, "Pause");
        inputManager.addListener(analogListener, "Left", "Right", "Rotate");
    }
    
    private ActionListener actionListener = new ActionListener()
    {
        public void onAction (String nombre, boolean keyPressed, float tpf)
        {
            if (nombre.equals("Pause") && !keyPressed)
            {
                isRunning = !isRunning;
            }
        }
    };
    
    private AnalogListener analogListener = new AnalogListener()
    {
        public void onAnalog(String nombre, float valor, float tpf)
        {
            if (isRunning)
            {
                if (nombre.equals("Rotate"))
                {
                    jugador.rotate(0, valor*speed, 0);
                }
                if(nombre.equals("Right"))
                {
                    Vector3f vector = jugador.getLocalTranslation();
                    jugador.setLocalTranslation(vector.x + valor*speed, vector.y, vector.z);
                }
                if (nombre.equals("Left"))
                {
                    Vector3f vector = jugador.getLocalTranslation();
                    jugador.setLocalTranslation(vector.x - valor*speed, vector.y, vector.z);                    
                }   
            }
            else
            {
                System.out.println("Press P to unpause.");
            }
        }
    };
}

Would you please point me out what I should fix?

Thank you.

Press the little exclamation mark on the left of the “public class HelloInput” line in the editor and let the SDK implement that method for you. The problem is what the title says.

Hi normen,

I just did let the SDK implement all abstract classes, as you said, but now I get the following error:

Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.UnsupportedOperationException: Not supported yet.

Also, I still don’t understand what the problem was initially, would you please elaborate on that?

Thanks.

Well remove that line that throws this exception :slight_smile: Its meant to remind you that you added methods you still have to implement.

An abstract class is a class that cannot be instantiated but has to be extended in your own implementation of it, it (possibly) defines a series of methods that have to be implemented in the extending class to function. In this case SimpleApplication is the (abstract) class you’re supposed to extend (to make it your own “not-simple” Application class) and it needs a simpleInitApp method that can be called to initialize your application.

https://docs.oracle.com/javase/tutorial/java/IandI/abstract.html

Just to notice: Both problems has no relation with JME, its pure Java basic knowledge.