Java - Build and run eclipse project from command line

后端 未结 4 681
臣服心动
臣服心动 2020-12-07 14:06

I have a java project written using eclipse ide and I want to run it through ssh on a different machine, but I have to do this using the command line and I don\'t know exact

4条回答
  •  清歌不尽
    2020-12-07 14:40

    You can run Java applications from the command line. The simplified syntax looks like this:

    java -cp  

    where:

    - list of directories and/or JAR-files where needed classes reside separated by ";" for Windows or ":" for linux (default classpath is "." - the current directory);

    - fully qualified name of the class containig main() method (for example, org.myself.HelloWorld)

    - various arguments for application if any.

    So, if you find the directory where Eclipse stored compiled classes (usually it's bin) you may use the command, like

    java -cp . my.package.MyClass
    

    Or, if you use some libraries and classes in other directories, it could be:

    java -cp some-cool-lib.jar:another-lib.jar:/some/directory/with/classes my.package.MyClass
    

提交回复
热议问题