简体   繁体   English

从命令行运行可编译的Java程序的问题

[英]issues of running a compilable java program from command line

I had a compilable java file under Eclipse, the source file is under the directory like 我在Eclipse下有一个可编译的Java文件,源文件在以下目录下

/home/workspace/testApplication/src/Test/test.java

I can run it from Eclipse by clicking "run as Java application". 我可以通过单击“以Java应用程序运行”从Eclipse运行它。 But if I want to run this problem from command line, how to do that? 但是,如果我想从命令行运行此问题,该怎么做?

Something like this: 像这样:

java -cp /home/workspace/testApplication/bin Test.test <app's command line args>

The "-cp ..." option gives the classpath, and it should include the absolute pathname of the directory tree into which Eclipse is writing ".class" files. “ -cp ...”选项提供了类路径,它应包括Eclipse正在向其中写入“ .class”文件的目录树的绝对路径名。 The "Test.test" argument is the fully qualified class name of your application's entrypoint class; “ Test.test”参数是应用程序入口点类的完全限定的类名; ie the one with the "main" method that starts the app. 即使用“ main”方法启动应用程序的程序。

If your application depends on other JAR files etc, they will need to be added to the classpath. 如果您的应用程序依赖于其他JAR文件等,则需要将它们添加到类路径中。


I should point out that you are violating the Java naming conventions. 我应该指出,您违反了Java命名约定。 A package name should be all lowercase, and a class name should be camel case with the first character being an uppercase letter. 包名称应全部为小写,类名称应为驼峰式,并且第一个字符为大写字母。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM