help i dount know what is wrong the code with app.start has an error and i tried for a week to fix it but i havent gotten anyware plz help me
just fix. the error. or provide. more info
is this enough info
package mygame;
import com.jme3.app.SimpleApplication;
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;
import com.jme3.input.controls.Trigger;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
/** Basic jMonkeyEngine game template. */
class UserInput {
private final static Trigger TRIGGER_COLOR =
new KeyTrigger(KeyInput.KEY_SPACE);
private final static Trigger TRIGGER_ROTATE =
new MouseButtonTrigger(MouseInput.BUTTON_LEFT);
private final static String MAPPING_COLOR = âToggle Colorâ;
private final static String MAPPING_ROTATE = âRotateâ;
private final static Trigger TRIGGER_COLOR2 =
new KeyTrigger(KeyInput.KEY_C);
public UserInput() {
}
public class Main extends SimpleApplication {
UserInput app = new UserInput();
@Override
/** initialize the scene here */
public void simpleInitApp() {
inputManager.addMapping(MAPPING_COLOR, TRIGGER_COLOR,
TRIGGER_COLOR2);
inputManager.addMapping(MAPPING_ROTATE, TRIGGER_ROTATE);
inputManager.addListener(actionListener,
new String[]{MAPPING_COLOR});
inputManager.addListener(analogListener,
new String[]{MAPPING_ROTATE});
// create a cube-shaped mesh
Box b = new Box(Vector3f.ZERO, 1, 1, 1);
// create an object from the mesh
Geometry geom = new Geometry(âBoxâ, b);
// create a simple blue material
Material mat = new Material(assetManager,
"Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
// give the object the blue material
geom.setMaterial(mat);
// make the object appear in the scene
rootNode.attachChild(geom);
}
private final ActionListener actionListener = new ActionListener() {
@Override
public void onAction(String name, boolean isPressed, float tpf) {
System.out.println("You triggered: "+name);
}
};
private final AnalogListener analogListener = new AnalogListener() {
@Override
public void onAnalog(String name, float intensity, float tpf) {
System.out.println("You triggered: "+name);
}
};
@Override
/** (optional) Interact with update loop here */
public void simpleUpdate(float tpf) {}
@Override
/** (optional) Advanced renderer/frameBuffer modifications */
public void simpleRender(RenderManager rm) {}
âââ
public static void main(String[] args) {
Main app = new Main();
âââ
app.start();
}
}
}
(says they got an error⌠doesnât say what the error is.)
Walks into mechanic: âHello, my car at home is broken can you tell me whatâs wrong?â
We will need to know something about what is wrong to help with fixing what is wrong.
Also, you might look at the post about how to format code blocks to help people read your code.
k i put the âââ exactlay ware the errors are also i am still learning code
WHAT IS THE ERROR?!?!?!?!?
Like. WHAT is it. Not WHERE is it. WHAT is it.
Just âerrorâ?
I donât think so.
What is the error. The error that happens. What is the information about the error? The error that happens has some information. It doesnât just say âerrorâ.
What is it?
the program fails to start
and the consol says this
run:
Error: Could not find or load main class mygame.Main
/Users/########/Library/Application Support/jmonkeyplatform/v3.2.0-prealpha-sdk1/var/cache/executor-snippets/run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)
AHAH!!! The error! Right there.
Could not find or load main class mygame.Main
You do not have a class named Main in the package mygame. Either reconfigure the project to point to the right class or relocate/rename your package/class.
You are perhaps still too early in your Java programming learning to start with something as advanced as 3D game programming. Do some tutorials. Write some simpler things.
thats the problem ITâS IN THE RIGHT FOLDER
Yes, but that class has errors in it.
Anyway, if you create a new game template based project and hit run then it should run. If not then your SDK is messed up.
If you create a new game template based project and modify it and it doesnât run then your modifications are busted.
You keep posting follow ups⌠your code clearly has compile errors. Yet you donât even tell us what the compile errors are. Iâm not sure we can help you because you are basically helpless.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mygame;
import com.jme3.app.SimpleApplication;
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;
import com.jme3.input.controls.Trigger;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
/** Basic jMonkeyEngine game template. */
public class Main extends SimpleApplication {
public static class UserInput {
private final static Trigger TRIGGER_COLOR =
new KeyTrigger(KeyInput.KEY_SPACE);
private final static Trigger TRIGGER_ROTATE =
new MouseButtonTrigger(MouseInput.BUTTON_LEFT);
private final static String MAPPING_COLOR = "Toggle Color";
private final static String MAPPING_ROTATE = "Rotate";
private final static Trigger TRIGGER_COLOR2 =
new KeyTrigger(KeyInput.KEY_C);
public UserInput() {
}
}
UserInput ui = new UserInput();
/** initialize the scene here */
@Override
public void simpleInitApp() {
inputManager.addMapping(UserInput.MAPPING_COLOR, UserInput.TRIGGER_COLOR,
UserInput.TRIGGER_COLOR2);
inputManager.addMapping(UserInput.MAPPING_ROTATE, UserInput.TRIGGER_ROTATE);
inputManager.addListener(actionListener,
new String[]{UserInput.MAPPING_COLOR});
inputManager.addListener(analogListener,
new String[]{UserInput.MAPPING_ROTATE});
// create a cube-shaped mesh
Box b = new Box(Vector3f.ZERO, 1, 1, 1);
// create an object from the mesh
Geometry geom = new Geometry("Box", b);
// create a simple blue material
Material mat = new Material(assetManager,
"Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
// give the object the blue material
geom.setMaterial(mat);
// make the object appear in the scene
rootNode.attachChild(geom);
}
private final ActionListener actionListener = new ActionListener() {
@Override
public void onAction(String name, boolean isPressed, float tpf) {
System.out.println("You triggered: "+name);
}
};
private final AnalogListener analogListener = new AnalogListener() {
@Override
public void onAnalog(String name, float intensity, float tpf) {
System.out.println("You triggered: "+name);
}
};
/** (optional) Interact with update loop here */
@Override
public void simpleUpdate(float tpf) {}
/** (optional) Advanced renderer/frameBuffer modifications */
@Override
public void simpleRender(RenderManager rm) {}
public static void main(String[] args) {
Main app = new Main();
app.start();
}
}
This should compile and run.
You better first learn how to write Java code.
A wild guess is that because you have no idea what you are doing then you are naming things âwhatever random thing occurs to youâ like calling your user input object âappâ and that is confusing the compiler.
âŚwhich we could have told you right away if the first thing you posted was the compile error you got.
As I posted in Slack today ⌠noobs need to learn how to crawl before they try to fly ⌠itâs the endless problem with noobs in technology
Cut and paste is NOT your friend my padawan
You know you either probably have two SDKâs on your computer and donât even know itâŚBecause I dealt with the same thing months ago whenever I had to redownload jmonkey and netbeans. ⌠just delete one of them and reinstall if it still does those âerrorsâ
OR⌠you could change your code of the actionlistener toâŚ
private ActionListener actionListener = new ActionListener({
public void onAction(String name,boolean isPressed,float tpf){
//insert beat up code
});
}
His issue is that he doesnât know what a compile error is, how to read it, or what to do about it. Itâs not really an SDK problem as it turns out. Just an operator problem.
That ActionListener code is right thoâŚright?
The fact that both of those had the same name is probably the real issue⌠and the compiler was probably saying exactly that.
The problem were simple syntax errors. I just renamed that to âui
â because that makes way more sense than being named âapp
â, but that wasnât the issue. There are still things in the code that are useless / unnecessary though.
Well, Iâm not a big Know-it-all about Java, but more of an intermediate user. But it was easy for me to see the errors, and with the help of NetBeans I didnât even have to think too much. But I can understand, that an absolute beginner was not able to make something of the compiler error message - since those can be kind of cryptic.