If you are referencing any external libraries, then you have to add them to the classpath. You can add it during compilation of the classes this way.

Go to the src directory and :

javac -classpath ".:<path_to_jar_file>" teamL/*.java

TO execute :

java -cp ".:<path_to_jar_file>" teamL.<class_name>

if your are using eclipse, then go to <project_directory>/bin/ here you can find the compiled classes (so you dont have to compile them) and directly run them using the above java command

Note: Since your classes are packaged under teamL package, you have to run the classes from outside the package by specifying the fully qualified name like teamL.ServiceEndpoint

Answer from Rakesh on Stack Overflow
๐ŸŒ
Javatpoint
javatpoint.com โ€บ how-to-run-java-program-in-eclipse
How to Run Java Program in Eclipse - Javatpoint
How to Run Java Program in Eclipse with oops, string, exceptions, multithreading, collections, jdbc, rmi, fundamentals, programs, swing, javafx, io streams, networking, sockets, classes, objects etc,
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ eclipse โ€บ eclipse_running_program.htm
Eclipse - Running Program
The quickest way to run a Java program is by using the Package Explorer view. In the Package Explorer view โˆ’ The same action can be performed using the Package Explorer view by selecting the class that contains the main method and clicking Alt +
๐ŸŒ
wikiHow
wikihow.tech โ€บ computers and electronics โ€บ software โ€บ programming โ€บ java โ€บ how to run java program in eclipse: beginner's guide
How to Run Java Program in Eclipse: Beginner's Guide
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..
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.

๐ŸŒ
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.
๐ŸŒ
MIT
web.mit.edu โ€บ 6.031 โ€บ www โ€บ fa17 โ€บ projects โ€บ fb1 โ€บ commandline.html
Running Java Programs with Command-Line Arguments
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.
Find elsewhere
๐ŸŒ
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.
๐ŸŒ
YouTube
youtube.com โ€บ ranko junction
how to run java program in terminal || how to run java program terminal in eclipse - YouTube
In this video we are going to see how to run java program terminal in eclipse#education #easy #viral #java #javaprogramming #terminal #eclipse #class #softw...
Published: December 14, 2023
Views: 886
๐ŸŒ
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 - The general syntax is java [class_name] The program will now execute and display any output in the terminal. Note that you should use the fully qualified name of the class containing the main method.
๐ŸŒ
YouTube
youtube.com โ€บ joe shepley
How to Run Java Files in Eclipse and Test Them on Terminal - YouTube
This video describes how to run java files on Eclipse, and once they are working on eclipse, I demonstrate how to find those files on your computer and make ...
Published: February 10, 2017
Views: 10K
Top answer
1 of 6
39
/*
 * put this in a file named CommandLineExample.java
 *
 */

class CommandLineExample
{
    public static void main ( String [] arguments )
    {
        System.out.println("Hello, world");
    }
}

type the following from the command line to compile it:

$ javac CommandLineExample.java

then you can run it from the command line like this:

$ java CommandLineExample
2 of 6
13

I would recommend using a variant of Eclipse Java IDE when working with jar development.

File > New > Java Project

Right Click "src" > New > Package > Name your package pack1.projectname.

Right Click "pack1.projectname" > New > Class > projectname as class name.

Write all the code your heart desires for this project. Java is a very interesting language. Always use packages with your class files, especially when you are sure that you will be importing your own code in other files. So you can do import pack1.projectname.handler.EventHandler;

File > Export > Java > JAR file, or Runnable JAR file > Next > export destination

This will package your jar file, appropriately with a META-INF manifest, also if you are developing an application or plugin, for anything like Minecraft. You will want a plugin.yml and config.yml file. You right click the project folder not "src" in the project explorer. Do New > File > plugin.yml and config.yml. Just a side note.

The reason I always use pack1 as my toplevel package identifier is of course so I can tell which pack I am working with as I update my project. I always do this to easily compare files I have updated, why I updated them, etc. etc. So initial distribution would be pack1.projectname. Next version pack2.projectname. Also, when not updating code in an entire file, you can just import pack1.projectname.handler.EventHandler; import pack2.projectname.builder.RandomFile; pack3.projectname.init.init; These is a very organized way to develop in Java using Eclipse.

Hope this helped you on your quest to beginning your projects in Java. I will not write Java code on stackoverflow unless the person asking shows a snippet of his own project, and just cannot break through his coders block. Practice makes perfect.

๐ŸŒ
YouTube
youtube.com โ€บ learningfromexperience
How to Compile and Run Java Program in Eclipse | Eclipse Clean and Build Process Explained - YouTube
Master the fundamentals of compiling and running Java programs in Eclipse! This beginner-friendly lesson guides you through every step:Project Creation: Set ...
Published: March 4, 2024
Views: 2K
๐ŸŒ
javaspring
javaspring.net โ€บ blog โ€บ how-to-run-java-program-in-terminal
How to Run Java Programs in the Terminal โ€” javaspring.net
The JDK includes both the compiler (javac) and the runtime (java); a Java runtime alone is not enough to compile programs. You can verify if it's installed by running the following commands in the terminal: ... If these commands return version information, you're good to go. Otherwise, you need to download and install a JDK. You can get one from the official Oracle website or from a free open-source build such as Eclipse Temurin (Adoptium) or Amazon Corretto.
๐ŸŒ
Slideshare
slideshare.net โ€บ home โ€บ education โ€บ to run java program in eclipse
To run java program in eclipse | DOCX
January 21, 2023 - To run a Java program in Eclipse, ... create a new Java project and package, add a new class, and run the program using the Run option or Ctrl+F11 keyboard shortcut....
๐ŸŒ
Eclipse
help.eclipse.org โ€บ latest โ€บ topic โ€บ org.eclipse.jdt.doc.user โ€บ tasks โ€บ task-launching_java_program.htm
Launching a Java Program
The simplest way to launch a Java program is to run it using a Java Application launch configuration. This launch configuration type uses information derived from the workbench preferences and your program's Java project to launch the program.