How to Run a Java Program Without IDE

By Aditya Dhanraj Add a Comment 4 Min Read
How-to-Run-a-Java-Program-Without-IDE

Developers love modern-day, robust Java IDEs, as they make the developer’s life simpler every day. However, there are benefits to knowing how to run a Java program without an Integrated Development Environment (IDE). Here, in this guide, we will discuss how to run a Java Program without IDE on the Windows operating system.

We will be using the Command Prompt to run Java programs without an IDE. Before proceeding, you need to install and set up the Java JDK on your Windows 11 computer. To do so, you can check out our linked guide. After that, follow along with the guide.

How to Write Java Code without IDE

To write a Java program, you can use any source code editor such as Notepad++, Sublime Text, etc. Let’s create a simple Java program that will print “Welcome to Coding Lap YouTube Channel!

Here, we’re going to use Notepad++ to create the Java program. Here is the Java code that will print the statement:

public class HelloYouTube {
public static void main( String []args ) {
System.out.println(Welcome to Coding Lap YouTube Channel!);
}
}

Your file name and class name must be the same. For example, if you create a HelloYouTube class, you need to name your file HelloYouTube.java and save it.

Once you have created your Java program, you can proceed to the next steps, where we will learn how to run a Java program without an IDE on Windows 11.

How to Run Java Program in Command Prompt

To run a Java program using the Command Prompt, you should have some basic knowledge of how to use the Command Prompt, as we will use it to run our Java program.

Before that, check whether Java and javac are set up. You can run these commands in the command prompt: java -version and javac. javac is a Java compiler that compiles Java code.

Once you have verified the Java installation, you can follow these steps to run the Java program with the Command Prompt:

1. Open Command Prompt and change the directory to Desktop, as I have saved my Java file at Desktop. For that, I will use the cd desktop command.

Note

I have saved my Java file on the Desktop with the file name HelloYouTube.java. I need to locate this file in the Command Prompt.

2. Next, to see all files in the directory, use the dir command. Here, you will get your Java file name.

3. To run your Java file. You need to create a Java class file of the HelloYouTube.java file. For that, run this command javac HelloYouTube.java on the command prompt. This will create a Java class file.

4. To run the Java file using the command prompt, run this command java HelloYouTube. This command will execute your Java code. As you can see in the screenshot below.

Conclusion

If you want to create and run a simple Java program and application, you can directly use the Command Prompt and run the javac and java commands. However, for complex Java programs, IDE is a perfect solution to use. You can set up IDE like Eclipse and IntelliJ for Java programming.

TAGGED:
Share This Article
Follow:
Aditya Dhanraj is a Web Developer by profession and Content Writer by passion. He loves to write about coding and programming. When he is not writing, he must be developing something!
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *