Adding jar to classpath when running from command line

前端 未结 5 1219
盖世英雄少女心
盖世英雄少女心 2021-01-02 02:43

Ok I know this question has been asked many many many times before, but I\'ve googled it and looked at examples and looked at questions on SO for the past month, and I serio

相关标签:
5条回答
  • 2021-01-02 03:19

    Your problem is min separator you are using. Separator ; is for windows. On Unix systems you should use : instead:

    java -classpath "bin:mysql-connector-java-5.1.19-bin.jar" MyProgram

    0 讨论(0)
  • 2021-01-02 03:22

    See:

    String pathSeparator = System.getProperty("path.separator");
    
    0 讨论(0)
  • 2021-01-02 03:29

    I would highly suggest you try --jar or -jar. I can't remember which it is, but those should settle you. Also, if you have the dev tools from apple, they have a jar packager.

    0 讨论(0)
  • 2021-01-02 03:32

    Use a ':' to separate your entries on Unix systems:

    java -classpath "bin:mysql-connector-java-5.1.19-bin.jar" MyProgram
    java -cp bin:mysql-connector-java-5.1.19-bin.jar MyProgram
    

    Eclipse converts it automatically.

    0 讨论(0)
  • 2021-01-02 03:44

    you did not set your main class in classpaht, try add ./ in -cp

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