How to Run an Application in Java


In this example, we will learn you how to run an application with no main method in Java.

Source Code

ppackage com.beginner.examples;

public class NoMain {

  // run with no main method
  static {
    System.out.println("OK!");
    System.exit(0);
  }
}

Output:

OK!
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments