【问题标题】:Classpath format for Windows command lineWindows 命令行的类路径格式
【发布时间】:2013-08-27 13:10:04
【问题描述】:

已经很久没有使用过 Windows 命令行了。如果文件都在我的桌面上,有人可以告诉我如何让它工作。谢谢!我也对<class-path> 感到困惑,我是把路径放在那里还是去掉<>

java -cp < class-path > peersim.Simulator example1.txt

【问题讨论】:

    标签: java command-line classpath


    【解决方案1】:

    类路径的默认值为“.”,表示只搜索当前目录。您可以附加应用程序所需的 jar 名称,并用分号 (;) 分隔。这是一个使用类路径运行应用程序的示例,其中 abc.jar 和 xyz.jar 是必需的 jar。

    java -classpath .;abc.jar;xyz.jar peersim.Simulator example1.txt
    

    【讨论】:

    • 抱歉,里面有很多库!非常感谢。
    【解决方案2】:
    java -classpath .;myjar.jar;lib/referenced-class.jar my.package.MainClass
    

    不需要括号。

    对于您的应用程序:

    java -classpath .;myjar.jar;lib/referenced-class.jar peersim.Simulator example1.txt
    

    如果您的应用程序使用来自 myjar 和其他的类

    【讨论】:

      猜你喜欢
      • 2011-02-08
      • 2014-11-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-19
      • 2019-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多