How do I run .class files on windows from command line?

前端 未结 4 2122
离开以前
离开以前 2020-12-06 00:06

I\'m trying to run .class file from command line. It works when I manually move to the directory it\'s stored in, but when I try something like this:

java C:         


        
4条回答
  •  生来不讨喜
    2020-12-06 00:54

    Assuming that Main.class does not have a package declaration:

    java -cp C:\Peter\Michael\Lazarus\  Main
    

    Java looks for classes in a "classpath", which can be set on the command line via the -cp option.

提交回复
热议问题