2013-02-12 130 views
-6

我在此處輸入java -classpath C:\blahblahblah\software_engineering\cs2.jar作爲建議的一部分:Why does my IDE find the JAR but my command line doesn't?命令行如何不能識別這個java命令?

我敢肯定,這是一個有效的命令,但我反而收到此累列表:

Usage: java [-options] class [args...] 
      (to execute a class) 
    or java [-options] -jar jarfile [args...] 
      (to execute a jar file) 

where options include: 
    -server  to select the "server" VM 
    -hotspot  is a synonym for the "server" VM [deprecated] 
        The default VM is server. 

    -cp <class search path of directories and zip/jar files> 
    -classpath <class search path of directories and zip/jar files> 
        A ; separated list of directories, JAR archives, 
        and ZIP archives to search for class files. 
    -D<name>=<value> 
        set a system property 
    -verbose[:class|gc|jni] 
        enable verbose output 
    -version  print product version and exit 
    -version:<value> 
        require the specified version to run 
    -showversion print product version and continue 
    -jre-restrict-search | -jre-no-restrict-search 
        include/exclude user private JREs in the version search 
    -? -help  print this help message 
    -X   print help on non-standard options 
    -ea[:<packagename>...|:<classname>] 
    -enableassertions[:<packagename>...|:<classname>] 
        enable assertions 
    -da[:<packagename>...|:<classname>] 
    -disableassertions[:<packagename>...|:<classname>] 
        disable assertions 
    -esa | -enablesystemassertions 
        enable system assertions 
    -dsa | -disablesystemassertions 
        disable system assertions 
    -agentlib:<libname>[=<options>] 
        load native agent library <libname>, e.g. -agentlib:hprof 
        see also, -agentlib:jdwp=help and -agentlib:hprof=help 
    -agentpath:<pathname>[=<options>] 
        load native agent library by full pathname 
    -javaagent:<jarpath>[=<options>] 
        load Java programming language agent, see java.lang.instrument 

    -splash:<imagepath> 
        show splash screen with specified image 

怎麼來的?

+0

你沒有告訴什麼的Java的Java文件來運行你只給了:

所以從另一個問題重複我的答案它是一個類路徑。 – 2013-02-12 22:05:42

+0

你讀過這份疲倦名單的前四行嗎? – reinierpost 2013-02-12 22:29:25

回答

1

你給它一個類路徑,但不是要執行的類的名稱。你也只有在你的類路徑中包含jar文件 - 而不是包含你的類文件的目錄。 (同時含有和cs2.jar目錄運行。)

java -cp .;cs2.jar CB 

+0

我一直在想分號分隔兩個單獨的命令。我很抱歉。謝謝你。 – user1971506 2013-02-12 23:21:30