How to run compiled java project from console, not from IntelliJ

前端 未结 3 854
广开言路
广开言路 2021-01-29 09:47

After the the demo project is compiled, there are many .class file in the out>production>testPrj>apidemo. Basically, each file will have one .class file

I expect to ente

3条回答
  •  执念已碎
    2021-01-29 10:04

    You need to provide the fully qualified name of the class with package name and not include ".class". So you need to place yourself in the parent directory to where ApiDemo.class is - i.e. out>production>testPrj.

    And then execute:

    $ java apidemo.ApiDemo
    

    Another way is to provide "out/production/testPrj" as the classpath:

    $ java -cp /path/to/out/production/testPrj apidemo.ApiDemo
    

提交回复
热议问题