9

I have a jar file : "CallMeMaybe.jar".

There is a static method callMe() in the main class callmemaybe.CallMeMaybe . Like it is possible to call the main() method from command line by running :

java -cp CallMeMaybe.jar callmemaybe.CallMeMaybe

Is there a way to directly call another static method than main() ?

I would like to do that :

java -cp CallMeMaybe.jar callmemaybe.CallMeMaybe.callMe()
1
  • 2
    main, is the main entry point. Is there a main method anywhere in there? Commented Jul 31, 2014 at 14:37

1 Answer 1

4

You can't call it directly, but just call it from your main method i.e.

public class Foo {
    public static void main(String[] args) {
        doSomething(args);
    }

    private static void doSomething(String[] args) {
        // your code here
    }
}

Although I don't see the point of the extra method.

Sign up to request clarification or add additional context in comments.

1 Comment

But what if you return a true/false value? You can't return a boolean from main

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.