Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call method in jar file with terminal?

I have a compiled project in a jar file and I need to call a method from it.How can I do that in ubuntu terminal?

like image 708
shift66 Avatar asked Oct 31 '11 06:10

shift66


2 Answers

You can not call any method from terminal or cmd of any class.

You can execute class through terminal.

If your jar is executable try: java -jar "Name of your Jar"

Or set the class path of your jar: java -classpath path-to-jar <package>.<classname>

like image 121
Sumit Singh Avatar answered Oct 18 '22 16:10

Sumit Singh


java -cp path/to/jar <package>.<classname>

example:

java -cp test.jar org.dekz.HelloWorld
like image 39
dekz Avatar answered Oct 18 '22 18:10

dekz