Code Problem

Hi i am trying to build my display window with this code and i get a problem that the variable display may not be initilised heres the code





//this is the problem line its more directly the “Main” method it says the above is if i change it it says that the ??? is public and should be diclared as ???.java any way i can fi this little prediciment? thanks

public class Main extends Application {



public static void Main(String[] args) {



Main app = new Main();

app.start(Display);

}





public static final JmeContext.Type Display; {



}

@Override

public void start(JmeContext.Type contextType)

{

}

@Override

public void initialize()

{

}

}

Hi, i think it would be best to get started by following this tutorial:



https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_simpleapplication

Your file should be named Main.java with a capital ‘M’ and the method should be called ‘main’ with a lowercase ‘m’.

public static void main(String[] args) {…}

Hey nehon i changed to Main.java and the method to main with lowercase and i did not change anything and larynx ill look at that i have been looking at some tuts that normen gave to me thankyou for the help all.

What is the name of the .java file? That name and your class name must match exactly.

The .java file is named Main.java exactly its kinda pissing me off because i know it should work and the method is now named main. Thanks again for your help pspeed

Can you repost your code in a java block so that we can read it? I see some odd braces and stuff but it’s hard to tell with it just as embedded text in a forum post.



Maybe start simple:

Main.java

[java]

public class Main {

public static void main( String[] args ) {

System.out.println( “Hello, world.” );

}

}[/java]



…and start adding things to it until it breaks.

How about you first learn basic Java programming before you start thinking about approaching (3D) game creation?

4 Likes

Yes i can re-post and about basic java, I guess its like im trying to learn chinese starting with verbs and nouns… i am kinda just having trouble were to start i have looked at the tutorials and have gone to a certain point on them…ill try fooling around with that pspeed and heres the new code some imports are unused i plan to use them later…really what this is for me is not attempting a 3d game but just fooling around with the Application import and learning from it.Agian Thanks.



package mygame;



import com.jme3.app.Application;

import java.lang.Enum;

import com.jme3.system.JmeSystem;

import com.jme3.system.JmeContext;

import com.jme3.math.Vector3f;

import com.jme3.light.DirectionalLight;

import com.jme3.math.ColorRGBA;

import com.jme3.material.Material;

import com.jme3.scene.Geometry;

import com.jme3.scene.shape.Box;

import com.jme3.renderer.RenderManager;



//*this is the problem line it is directly the Main part.

public class Main extends Application {



public static void main(String[] args){



Main app = new Main();

app.start(Display);





}





public static final JmeContext.Type Display; {



}

@Override

public void start(JmeContext.Type contextType)

{

}

@Override

public void initialize()

{

}

public void simpleInitApp()

{





Box b = new Box(Vector3f.ZERO, 1, 1, 1);

Geometry geom = new Geometry(“Box”, b);

geom.updateModelBound();



Material mat_stl = new Material(assetManager, “Common/MatDefs/Misc/SimpleTextured.j3md”);

mat_stl.setColor(“m_Color”, ColorRGBA.Blue);

geom.setMaterial(mat_stl);



}





}

Please click the little Java button and put it in the java block.



I think you have a strange set of {} right after public static final JmeContext.Type Display and I’m not even sure what that line is there for.

Oh, and the original error is telling you that the name of your .java file (including the path for the package) and the actual class in that file does not match. Only you can figure out why that is happening as we can’t see your system. The contents you pasted should be in src/mygame/Main.java… note: not main.java. Case must match.



At that point, you are sort of on your own as it’s impossible to debug from here and it is a straight forward general Java related issue.

Okay thanks alot i fixed my problem with your help. Thanks alot pspeed you have been very understanding and patient with me and i really appreciate the help from you!.