How to call JAVA class methods using shell script? -


this question has answer here:

i have been working on solution. need call method written in java program using shell script command. there way call non main methods.

i'm using .sh file's (start & stop) program. way can write script call non "main" method.

only main method can called shell script.

example is:

class test {     public static void main(string []arg)     {         string input = arg[0];         if ("start".equals(input))             //call start method         else if ("stop".equals(input))             //call stop method         else             //define default behaviour     } } 

shell

java -cp /path/class test start 

this call main method of test class , pass start argument.

and -cp represents path java class file. assumption java's path set in environment.

edit : can not call non main method directly, instead can pass argument main method , based on input(use if-else) call method start or stop


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -