Simply navigate to the directory that the class file exists in and use

java -classpath . myClass

Edit: You can replace the . with any classpath. For example, to find your classpath you can use echo %CLASSPATH%

Edit: Looks like there's quite a bit of information that might help you here.

Answer from alexcoco 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,
๐ŸŒ
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..
๐ŸŒ
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
Find elsewhere
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.

๐ŸŒ
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
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
๐ŸŒ
YouTube
youtube.com โ€บ watch
how to compile and run java program in eclipse - YouTube
how to compile and run first java program in eclipse#javatutorialforbeginners #javatutorial #javaprogram
Published: November 7, 2020
๐ŸŒ
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 ...
๐ŸŒ
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, ... Java perspective. Then, they 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
This launch configuration type uses information derived from the workbench preferences and your program's Java project to launch the program. In the Package Explorer, select the Java compilation unit or class file with the main method you want to launch. Press the Run [ ] button in the workbench ...
๐ŸŒ
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 - Simple javac and java commands that I could run (or add to a Makefile) such that the .class files generated would go into the bin folder created in the eclipse project.