Running Java Program from Command Line Linux

前端 未结 4 1986
無奈伤痛
無奈伤痛 2020-12-08 08:24

I am not very experience with java and this is driving me crazy. I wrote a java program FileManagement and I need to run it from the command line.

I can

4条回答
  •  再見小時候
    2020-12-08 08:53

    If your Main class is in a package called FileManagement, then try:

    java -cp . FileManagement.Main
    

    in the parent folder of the FileManagement folder.

    If your Main class is not in a package (the default package) then cd to the FileManagement folder and try:

    java -cp . Main
    

    More info about the CLASSPATH and how the JRE find classes:

    • How Classes are Found
    • Setting the class path (Solaris/Linux)
    • http://en.wikipedia.org/wiki/Classpath_(Java)

提交回复
热议问题