Saturday, December 13, 2025
HomeLanguagesJavaHow to Run Java Program?

How to Run Java Program?

Java is a popular, high-level, object-oriented programming language that was developed by James Gosling and his team at Sun Microsystems (now owned by Oracle Corporation) in the mid-1990s. It is widely used for developing various kinds of software, including web applications, desktop applications, mobile applications, games, and more.

Step by Step Implementation

To run a Java program, you need to follow these steps:

Step 1: Install Java Development Kit (JDK) on your computer. You can download the JDK from the Oracle website or any other reliable source.

 

Step 2: Write your Java code in a text editor such as Notepad or any other code editor. Save the file with a .java extension and file type as ‘All files’ in the desired location.

java-program-min

Step 3: Open the command prompt (Windows) or terminal (Mac or Linux).

cd1

Step 4: Navigate to the directory where you saved your Java code using the “cd” command.

cd2

Step 5: Compile your Java code by typing “javac [filename].java” in the command prompt/terminal. This will create a .class file in the same directory.

cd3

Step 6: Run your Java program by typing “java [filename]” in the command prompt/terminal. The program will execute and produce the output.

cd4

To know about the relation between the java filename and java class name, please refer to this article – Myth about java file name and java class name.

RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32447 POSTS0 COMMENTS
Milvus
105 POSTS0 COMMENTS
Nango Kala
6816 POSTS0 COMMENTS
Nicole Veronica
11952 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12031 POSTS0 COMMENTS
Shaida Kate Naidoo
6951 POSTS0 COMMENTS
Ted Musemwa
7202 POSTS0 COMMENTS
Thapelo Manthata
6898 POSTS0 COMMENTS
Umr Jansen
6882 POSTS0 COMMENTS