Kind of old question I know, but if you want to know command prompt for running Eclipse-based project (i.e the one that Eclipse uses)

  1. Run your project into Eclipse
  2. Goto Debug perspective
  3. (on my screen anyway) Window in top left corner should have a little 'debug' tab.
  4. Right click on name of your project, select Properties at the bottom of drop-down
  5. Click on the 'Command Line' field (this is what you probably want).
  6. Press [ctrl]+A & [ctrl]+C to select and copy
  7. Either paste this into command line, or
  8. (what I did) in Windows, create new *.bat text file and paste it in there ... now double clicking on that file should run your java proj.

Pretty useful if you wanna run something out of eclipse and are lazy like me.

BTW I needed this for exporting project for a uni assignment. Of course, they wanted to see code in *.java files too and above just uses *.class files Eclipse builds on the fly. To make batch compile your *.java files & then run you need to put together an appropriate javac command before the javaw line you got from process above and adjust accordingly - look at Java Docs for this. Eclipse has done most of hard work with library class paths though (I was using a few libs).

Answer from Jon on Stack Overflow
🌐
Stack Overflow
stackoverflow.com › questions › 34140373 › how-to-make-eclipse-run-my-program-in-a-terminal
java - How to make Eclipse run my program in a terminal - Stack Overflow
@Perdomoff That is an entirely different question, that one is about why eclipse doesn't find the jarfile or something, this one is about how to make eclipse run the program in the terminal by default. Sorry if it's unclear. ... It is possible and already answered here and here There is one more [link]idiotechie.com/how-to-use-cmd-prompt-inside-eclipse ... First, go to the directory with your *.java file.
Top answer
1 of 4
15

Kind of old question I know, but if you want to know command prompt for running Eclipse-based project (i.e the one that Eclipse uses)

  1. Run your project into Eclipse
  2. Goto Debug perspective
  3. (on my screen anyway) Window in top left corner should have a little 'debug' tab.
  4. Right click on name of your project, select Properties at the bottom of drop-down
  5. Click on the 'Command Line' field (this is what you probably want).
  6. Press [ctrl]+A & [ctrl]+C to select and copy
  7. Either paste this into command line, or
  8. (what I did) in Windows, create new *.bat text file and paste it in there ... now double clicking on that file should run your java proj.

Pretty useful if you wanna run something out of eclipse and are lazy like me.

BTW I needed this for exporting project for a uni assignment. Of course, they wanted to see code in *.java files too and above just uses *.class files Eclipse builds on the fly. To make batch compile your *.java files & then run you need to put together an appropriate javac command before the javaw line you got from process above and adjust accordingly - look at Java Docs for this. Eclipse has done most of hard work with library class paths though (I was using a few libs).

2 of 4
11

For building you can export an Ant build file. Just right click on the project -> Export -> Ant buildfiles. On the command promt use ant <buildfile> to build the project.

Take a look at this answer: Eclipse: export running configuration for running the eclipse project from the console.

Discussions

eclipse - How to run Java programs from the terminal? - Stack Overflow
Also why can't I run the same from my eclipse? ... As i told earlier, don't use -jar to add jar files into the classpath ! to make it easier, copy the jar file inside the src folder, then javac -cp . teamL. so if ServiceEndpoint is your main class, then you have to use java -cp . More on stackoverflow.com
🌐 stackoverflow.com
November 7, 2011
eclipse - Run java with terminal - Stack Overflow
Is it possible to run in terminal java program that contains multiple files? When I'm using javac main.java terminal can't find any files except main.java More on stackoverflow.com
🌐 stackoverflow.com
April 26, 2017
How to run an eclipse java project using the command line
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/javahelp
1
2
March 27, 2023
Java - Build and run eclipse project from command line - Stack Overflow
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 More on stackoverflow.com
🌐 stackoverflow.com
🌐
Ymichael
ymichael.com › 2014 › 09 › 24 › build-and-run-eclipse-java-projects-on-the-command-line.html
Build and run eclipse java projects from the command line
September 24, 2014 - Run the following command to compile your .java file in src and put them in bin ... My package was called cs5223 and I was trying to build cs5223.Server.java (which was the entry point into my project). ... Once you've compiled your .java files, you run them using the following command.
🌐
Eclipse
help.eclipse.org › latest › topic › org.eclipse.jdt.doc.user › tasks › task-launching_java_program.htm
Launching a Java Program
Alternatively, select Run As > Java Application in the Package Explorer pop-up menu, or select Run > Run As > Java Application in the workbench menu bar, or select Run As > Java Application in the drop-down menu on the Run tool bar button. Your program is now launched, and text output is shown ...
🌐
Medium
medium.com › @burakkocakeu › how-to-run-your-java-program-on-terminal-b4956e7102a8
How to Run your Java Program on Terminal | by Burak KOCAK | Medium
January 29, 2023 - You can execute the program by using the java command followed by the name of the class which contains the main method. The general syntax is java [class_name] The program will now execute and display any output in the terminal.
Find elsewhere
🌐
MIT
web.mit.edu › 6.031 › www › fa17 › projects › fb1 › commandline.html
Running Java Programs with Command-Line Arguments
filename1 filename2 … are the list-definition filenames that you wish to load. You can also specify command-line arguments in Eclipse using the menu command Run → Run Configurations, choosing the class containing your main() method in the dialog box, then selecting the Arguments tab. Enter your arguments in the Program Arguments box, not the VM Argumentx box. Eclipse can also export your program as a “runnable JAR file” that contains all the code in a single file.
🌐
Reddit
reddit.com › r/javahelp › how to run an eclipse java project using the command line
r/javahelp on Reddit: How to run an eclipse java project using the command line
March 27, 2023 -

Hello,

I am making this java project for a class that I am taking, and the project has so many classes, packages, and some .jar libraries as well as using another project we made before. I always wondered how does eclipse compile and run all that mess and when I go to the directory after running in eclipse, I find no exe file or anything like that.

I want to be able to copy my folders and put them on another computer and compile and run them without eclipse being installed. Can someone please help me with that because I tried and I failed very hard.

I know that eclipse makes a folder of its own that stores settings and stuff, can I run my project on eclipse and then go to that folder and take some information from it and use it?

Thank you

Top answer
1 of 1
1
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
🌐
TutorialsPoint
tutorialspoint.com › eclipse › eclipse_running_program.htm
Eclipse - Running Program
If a Run configuration has already been created you can use it to start the Java application by selecting Run Configurations from the Run menu, clicking on the name of the run configuration and then clicking on the Run button.
🌐
Wikihow
wikihow.com › computers and electronics › software › programming › java › how to compile and run a java program using command prompt
How to Compile and Run a Java Program Using Command Prompt
September 28, 2025 - Type "javac [filename] and press "Enter" to compile the program. Type "java [filename]" and press "Enter" to run the Java program after it is compiled. ... Save the program. You can create a Java program using a simple text editing program like ...
🌐
Colorado State University
cs.colostate.edu › helpdocs › eclipseCommLineArgs.html
How To Use Command Line Arguments in Eclipse
The detailed instructions are in the next section, complete with screenshots from the Welcome class in Eclipse. Two other example programs are described in the last section. Basically, it's simple. Click on Run -> Run (not Run Last Launched). In the window shown below, notice that the Welcome ...
🌐
freeCodeCamp
freecodecamp.org › news › how-to-execute-and-run-java-code
How to Execute and Run Java Code from the Terminal
March 10, 2022 - We run the .class file to execute the Java programs. For that, we use the command java class_file_name_without_the_extension. Like, as our .class file for this is Main.class, our command will be java Main.
🌐
Wikihow
wikihow.com › computers and electronics › software › programming › java › how to run java program in eclipse: beginner's guide
How to Run a Java Application in Eclipse - Programming
January 27, 2026 - Download and Install Java, and Eclipse if the programs are not yet installed. ... Create a New Java Project. ... Create a new class with following File > New > Class.. ... Enter name of the class and press finish. . ... Enter code statement System.out.println("Hello World"); and Save (Shortcut : CTRL+S). ... Run Program as shown in the image..
🌐
LabEx
labex.io › tutorials › java-how-to-compile-and-run-a-java-program-in-the-terminal-413960
How to compile and run a Java program in the terminal | LabEx
Open a terminal and navigate to the directory where you saved the HelloWorld.java file. Compile the Java source code using the javac command: ... After running this command, you should see a new file called HelloWorld.class in the same directory.
🌐
Quora
quora.com › How-do-I-run-a-Java-file-in-Terminal
How to run a Java file in Terminal - Quora
Answer (1 of 3): This is an easy one to search but in short, you need the java runtime installed, as well as javac. The SDK should have both the jre and the compiler. On Ubuntu, I would run, “sudo apt install openjdk-8-jdk”. Your java file needs to have a “public static void main(String[] ...