Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java - Build and run eclipse project from command line

Tags:

java

eclipse

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 exactly how.

I am a beginner at both shell commands and java.

Could you please give me a useful link with answers regarding this question, or perhaps a set instructions of how to do this?

like image 347
Simon Avatar asked Mar 26 '11 09:03

Simon


People also ask

How do I compile and run a program in Eclipse?

Step 1: Open Eclipse and click File > New > Java Project. Step 2: Provide the Project Name and click on the Finish button. Step 3: In the Package Explorer (left-hand side of the window) select the project which you have created. Step 4: Right-click on the src folder, select New > Class from the submenu.

Can I use Java from the command line?

While there are many IDEs with built-in execution capabilities (Eclipse and IntelliJ for example), Java can also be run directly from the command line.


1 Answers

Maven or Ant are the best option but for an Eclipse-only solution
you can choose File -> Export and select Java -> Runnable JAR File
then transfer the JAR file to your other machine and run this from the command line:

java -jar YOUR.JAR 
like image 136
Russ Hayward Avatar answered Oct 13 '22 17:10

Russ Hayward