Calling static jave method from .sh file

Viewed 49

I have a jar files that holds alot of classes, in each class there are static methods that i have to call them from .sh file.

I have Function class for each module, this class aggregate all the methods in the module.

example:

public class Functions{
    public static String e1(){return e1.e1();}
    public static Integer e2(){return e2.e2();}
}
public class e1{
    public static String e1(){
        //do something
    }
}
public class e2{
    public static Integer e2(){
        //do something
    }
}

I want to call the functions in Function class from sh file:

result=$jar.Functions.e1()

I readed that this is the only solution:

"The only java method you can call from a shell script is the main method of a class, by starting that class with a java command line execution."

is it correct?

1 Answers

I created a module of runners and in this module I created alot of main classes, Each main class run's a static function as mentioned above. Then i called the desairable main from the bash function with java command.

Related