1

Is there a class called 'main' or something that java looks for in your project?

If it finds it, does the compiler take the 'main.class' as a starting point for compilation?

I don't know what to call my main class, whether there is even such a thing, or if more than one class act in tandem to control how the program works &/or call all the other classes.

I have a little experience in programming Minecraft mods, but that is also a bit scanty, so it would be awesome if you guys helped me out =]

Raghav
  • 39
  • 5

3 Answers3

2

When the JVM starts it will run a method named main with the signature:

public static void main(String args[])

When you start the JVM you tell it which class to use to find the main method. Alternatively you can start the JVM with a jar file, in which case it will look at the manifest in order to determine which class's main method to use.

For the jar method you execute the JVM like java -jar myjar.jar and define the main class in the manifest file with the Main-Class attribute.

Otherwise you start the JVM like java com.package.MyMainClass

Alex Figliolia
  • 437
  • 2
  • 5
0

At compilation time, it doesn't usually matter - you just specify all the source files you want to compile. (You can specify a subset and the compiler will find other source files it needs, but it's better to specify everything you want compiled.)

When you execute a Java program from the command line, you specify the class containing the main method:

java com.foo.MyAwesomeApp
Jon Skeet
  • 1,261,211
  • 792
  • 8,724
  • 8,929
0

In runnable jar files, there should be META-INF/MANIFEST.MF file with Main-Class specified.

MGorgon
  • 2,435
  • 15
  • 37