How to call method in jar file with terminal?

后端 未结 4 678
粉色の甜心
粉色の甜心 2021-01-17 16:34

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?

4条回答
  •  长发绾君心
    2021-01-17 16:44

    I need to call a method from it.

    This is not very specific statement. if you are interested to call main method of your Main class then you can do

    java -jar path/to/yourjar/yourJar.jar
    
    • JAR Basics

    if you want to call a method from this class from another class then you need to add this jar into your classpath and then you can access other methods. but since you wrote from terminal I assume the first approach fits for you

提交回复
热议问题