How to Run a Java Program Without IDE?

Java program without IDE

Developers love the robust modern-day Java IDEs, and they make the developer’s life simpler daily. But there are benefits to knowing how to run a Java program without IDE. 

We are going to use Command Prompt to run Java programming. Before this, we have to install and set up Java JDK on your windows 10 computer.

Also Read: How to Install and Setup Java JDK on Windows 10

How to Write Java Code without IDE

To write Java code you can use any source code editor like Notepad++, Sublime Text, Atom, etc. Let us create one simple Java program which will print “Welcome to thecoderworld YouTube Channel!“.

Here we are going to use Notepad++ to create the Java program. Here is the snapshot:

public class HelloYouTube {

     public static void main( String []args ) {

	System.out.println("Welcome to thecoderworld YouTube Channel!");

	}
}

Note:- Your file name and your class name must be same. For example, I create a “HelloYouTube” class, to save this code I have to name my file as HelloYouTube.java and save the file.

So this way you can create your Java program with the help of Notepad++.

Also Read: How to Install Notepad++ on Windows 10

How to Run Java Program in Command Prompt

In this section, we are going to discuss How to Run a Java Program Without IDE. Here are the steps:

Note:- I have saved my Java program at “Desktop” and my Java file name is “HelloYouTube.java”

To check whether the Java and javac is setup or not, you can use these commands in command prompt “java -version” and “javac“. javac is a Java compiler which compiles Java Code.

Also ReadWhat is Java Compiler (Javac)?

Step 1: Open Command Prompt and change the directory. So, I have saved my Java file at Desktop I will use “cd desktop” command.

Step 2: Now to see all files in the directory, use “dir” command, there you will see your java file.

Step 3: To run your Java file you have to create a Java class file of “HelloYouTube.java”. For that use this command “javac HelloYouTube.java”

Step 4: Now to run the Java file using this command “java HelloYouTube”. This command will execute your Java code.

Conclusion

An IDE is often proved to be a headache for building and executing simpler programs and applications. In such sort of cases, directly applying javac and java comes pretty handy to build and execute the programs.

Hope this was a helpful article for you. If you have a question in your mind, then leave a comment. We will be thankful to help you!

Exit mobile version