Calling a static jar class method from command line

kaligne

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()
bcsb1001

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Calling a static method inside a class in jar file

From Dev

How to call public static String method from jar from command-line?

From Dev

calling static method from inside the class

From Java

Calling static method on a class?

From Dev

Calling ES6 class constructor from class static method

From Dev

Calling a non-static method from outside the class

From Dev

Trouble calling a non-static method from an abstract class

From Dev

Calling non-static method from another file/class

From Dev

Execute Java Class from JAR on Linux command line

From Java

How to run a test class in a jar file from command line?

From Dev

Calling a method from a class

From Dev

Ruby class with static method calling a private method?

From Dev

Calling a non static method from a in a static context

From Java

calling a super method from a static method

From Java

Calling static method in test class(Junit)

From Dev

Calling a static method of a class using reflection

From Dev

PHP Calling a function within a static method of a class

From Dev

Passing a class as argument to a method, then calling static methods

From Dev

PHP, calling static method on class property

From Java

System.out not working when calling jar-file from Windows command line

From Dev

Calling protected ctor of inheriting class from within static template method of base class fails

From Dev

calling a static method from template class from other file C++

From Dev

Calling and passing to a method from class

From Javascript

Calling a class method from the constructor

From Dev

Calling method from State class

From Dev

Calling a function from a class method

From Dev

Calling method from a different class

From Dev

calling a method from tkinter class

From Dev

Calling a method from another jar file

Related Related

  1. 1

    Calling a static method inside a class in jar file

  2. 2

    How to call public static String method from jar from command-line?

  3. 3

    calling static method from inside the class

  4. 4

    Calling static method on a class?

  5. 5

    Calling ES6 class constructor from class static method

  6. 6

    Calling a non-static method from outside the class

  7. 7

    Trouble calling a non-static method from an abstract class

  8. 8

    Calling non-static method from another file/class

  9. 9

    Execute Java Class from JAR on Linux command line

  10. 10

    How to run a test class in a jar file from command line?

  11. 11

    Calling a method from a class

  12. 12

    Ruby class with static method calling a private method?

  13. 13

    Calling a non static method from a in a static context

  14. 14

    calling a super method from a static method

  15. 15

    Calling static method in test class(Junit)

  16. 16

    Calling a static method of a class using reflection

  17. 17

    PHP Calling a function within a static method of a class

  18. 18

    Passing a class as argument to a method, then calling static methods

  19. 19

    PHP, calling static method on class property

  20. 20

    System.out not working when calling jar-file from Windows command line

  21. 21

    Calling protected ctor of inheriting class from within static template method of base class fails

  22. 22

    calling a static method from template class from other file C++

  23. 23

    Calling and passing to a method from class

  24. 24

    Calling a class method from the constructor

  25. 25

    Calling method from State class

  26. 26

    Calling a function from a class method

  27. 27

    Calling method from a different class

  28. 28

    calling a method from tkinter class

  29. 29

    Calling a method from another jar file

HotTag

Archive