How to run Java .jar without MANIFEST.MF?

后端 未结 4 1073
我寻月下人不归
我寻月下人不归 2021-02-07 01:33

Is it possible to run a Java app which doesn\'t contain MANIFEST.MF file? Of course, there\'s static main method,just lacks manifest file. And the app

相关标签:
4条回答
  • 2021-02-07 02:03

    Of course! Just use this:

    java -cp MyJar.jar com.example.Main
    
    0 讨论(0)
  • 2021-02-07 02:04

    You can also add the manifest, with the following command:

    jar  -uvfe  your.jar foo.bar.Baz
    java -jar your.jar        # tries to run main in foo.bar.Baz
    
    0 讨论(0)
  • 2021-02-07 02:19

    It is possible, you can specify the class to run from the command line:

    java -cp yourJar.jar your.main.Class
    

    Same question here:

    How to run a class from Jar which is not the Main-Class in its Manifest file

    0 讨论(0)
  • 2021-02-07 02:23

    Yes , use this

    java -cp myJar.jar package.className

    0 讨论(0)
提交回复
热议问题