How to execute a Java method from inside shell scripts?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can only call the
mainmethod. Design yourmainmethod such that it calls the method you want.When I say call
mainmethod, you don’t explicitly invoke it. It’s the only entry point to a java program when you invoke it.If your class looks like:
You can use the following command line to invoke the
mainfrom within the directory where you can findcom/foo/Test.class(If you’re in theclassesdirectory in the structure shown far below):If you want to do so from a different (See the directory structure far below) directory, then you’ll have to set classpath.
Assume the below directory structure for clarity.