Can I invoke a java method other than main(String[]) from the command line?
Can I invoke a java method other than main(String[]) from the command line?
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.
If you install a REPL for a JVM language (Groovy probably takes the least work to get started with), then you can invoke Java methods at the REPL prompt (Groovy’s is called groovysh).
groovyshhas some odd features (my least favorite bit is that declaring variables withdefdoesn’t do what you’d think it should) but it’s still really useful. It’s an interesting feature that Groovy doesn’t respect privacy, so you can call private methods and check the contents of private variables.Groovy installs include groovysh. Download the zip file, extract it somewhere, add the location of the bin directory to the path and you’re good to go. You can drop jars into the lib folder, for the code you’re running and libraries used by that code, and Groovy will find them there.