2013-02-12 133 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