user785099
user785099

Reputation: 5563

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

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

I can run it from Eclipse by clicking "run as Java application". But if I want to run this problem from command line, how to do that?

Upvotes: 0

Views: 115

Answers (1)

Stephen C
Stephen C

Reputation: 719561

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. The "Test.test" argument is the fully qualified class name of your application's entrypoint class; i.e. the one with the "main" method that starts the app.

If your application depends on other JAR files etc, they will need to be added to the classpath.


I should point out that you are violating the Java naming conventions. A package name should be all lowercase, and a class name should be camel case with the first character being an uppercase letter.

Upvotes: 1

Related Questions