This site requires JavaScript, please enable it in your browser!
Greenfoot back
joandvgv
joandvgv wrote ...

2015/2/20

Where do I get the main class?

joandvgv joandvgv

2015/2/20

#
Ok, I think I may messed up with my other post about exporting greenfoot projects. What I need is to get the directory where the Main class is saved. Ok, I know I have like 10 classes in my project's folder. But none of these is my the class greenfoot uses as the main one. Please, any help or comment will help.
Super_Hippo Super_Hippo

2015/2/20

#
What is a "Main" class?
joandvgv joandvgv

2015/2/20

#
Well, a 'main' class is obviously, the main one. You don't see it in greenfoot because of the World-Actor stuff, but I think it is implicit and it's the one that contains the "main" method. For example:
1
2
3
4
5
class HelloWorldApp {
    public static void main(String[] args) { //Main method.
        System.out.println("Hello World!"); // Display the string.
    }
}
Super_Hippo Super_Hippo

2015/2/20

#
Ah, it's that java stuff I never understood which is fortunately not needed in Greenfoot. Well, yeah, I don't think I can help you with that...
joandvgv joandvgv

2015/2/20

#
Yep. Neither did I. Never mind, thanks for taking time to answer.
danpost danpost

2015/2/20

#
I would just try different things to see if it works. Maybe start with the path to the folder the project is in and then path to the jar file itself from there. Maybe it might work -- maybe not. I would think the jar file would contain a class (presumably your initial world class) with a 'public static void main(String args)' method already created within it. You may also have to include a path to the classes that greenfoot supplies. The link I gave above shows an example of multiple paths for the first part of the command line. Like I said, try different things -- you might get lucky.
joandvgv joandvgv

2015/2/20

#
Ok then, I'll try that. Seems like it's going to work, because the other tool (Jar2Exe) got the main class inmedeately when I upload the .jar
You need to login to post a reply.