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?
1 Answer 1
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.
4 Comments
Test.test is the fully qualified name of the class with the main method. See this Oracle technote for Windows: Setting the class path ~nix. You will generally want to avoid the CLASSPATH environment variable.