[Newbie's Questions] – initializing an app

Hello JME community! I’m a student, learning the JME3 engine for the first time, and by the end of the semester I aim to know the system well enough to be able to make a tutorial! I’ll be asking little nagging questions along the way to make sure I understand why some things are done the way they are in the engine.



My first question is this: Why is it that you must initialize your game class ( “HelloJME3” in this example ) from inside it, in the main() function?

[java]
public class HelloJME3 extends SimpleApplication {

public static void main(String[] args){
HelloJME3 app = new HelloJME3();
app.start(); // start the game
}
}
[/java]


Does this imply that you can package other app classes with this class and start those apps instead of this one by calling them from the main() function or maybe another function?

Thank you for your time! :)

You sure can create different apps inside of the main method. It is just a convenience of java to allow you to instantiate your class inside of itself. You can of course have a different class to bootstrap your main jme app class.



This tutorial talks about java and main methods.

Thanks a lot! :smiley:

I’m also learning Java this semester in a seperate class, which is unfortunate because knowing it beforehand would greatly help out with my learning of JME, but it’s kind of fortunate because it’ll supplement my learning of Java as I go along.

I do have a question about the main() method though, does the “static” qualifier mean that it’s a method that exists in the class ‘template’, and will execute when an object of the class is instantiated, but will not exist in the object for it to call on later?

Static methods are executed on the class itself: Foo.someStaticMethod()



The are not executed on an instance.



The Java.exe looks for a static main() method on whatever class it was provided. No objects are instantiated until your main method creates them with “new”.