简体   繁体   中英

How to run a Java program with external library from CLI

I am using IntelliJ for a Java project. My project structure looks something like this:

Crawler
    |----.idea
    |----lib
            jsoup-1.7.3.jar
    |----out
        |----production
            |----Crawler
                |----App
                    App.class
    |----src
        |----App
            App.java
    Crawler.iml

Now when I run the app from within IntelliJ, it loads the external lib and runs perfectly.

How should I run it from the command-line?

Unix (Linux, MacOS):

cd <path>/Crawler
java -cp out/production/Crawler:lib/jsoup-1.7.3.jar App.App

Windows:

cd <path>\Crawler
java -cp "out\production\Crawler;lib\jsoup-1.7.3.jar" App.App

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM