Static method not being called Java

InfinitePower563 :

Since the main method is static, it should be able to be called statically. Therefore, I use:

package prototype.server.main;

import javax.swing.JFrame;
import prototype.server.main.gui.Swing;

public class Runtime {
    public static void main(String[] argv) {
            Swing swing = new Swing(true, argv[0]);

        @SuppressWarnings("unused")
            JFrame maingui = swing.getGuiFrame();
    }
}

as the static-main code, then call using:

import prototype.server.main.Runtime;

public class Main {
     Runtime.main(new String{"f"});
}

to call the static method, but Eclipse is giving me an error. Please help and thank you in advance.

Ahmet OZKESEK :

There are two bugs we need to fix;

    import prototype.server.main.Runtime;

public class Main {
// add constructor, or method that you can call another method
// or make this static { ... } block that fits you
public Main() {
//do not forget [] for array
     Runtime.main(new String[]{"f"});
}
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=370904&siteId=1