execute jar without a main?

executable-jar, jar, java, program-entry-point

Solution

You must have a main method.

The signature for main needs to be:

public static void main(String[] args){
    // Insert code here
}

Therefore, you can call your method getX inside the main method.

Problem

Can I execute a jar file without having a main class, in this way: ``` java -jar my_jar.jar -getX arg1 arg2 ... ``` Knowing that I have a method called getX with takes arg1 arg2 ... as arguments. Any idea?

Original source

Related problems