Site icon TestingDocs.com

How to compile and run Java program without IDE?

Overview

In this tutorial, we will learn the steps involved to compile and run the Java program without IDE. Detailed steps are shown below:

Steps

To compile and run Java program we require an editor( ex Notepad, TextPad etc ), java compiler ( javac ) and java.

We can create and edit a java program in Notepad editor and save it as a file with the .java extension.

Create a file ( Example.java ) with the help of text editor. You can choose your favorite editor like Notepad , TextPad etc.The filename should be the class name.

 

Type in the below sample program and save the file.

 

public class Example {
public static void main(String args[]) {
System.out.println("This is an example class"); }
}

 

 

Open Command prompt and cd to the path of the file.

Compile the java file, with command line ( /> javac Example.java )

The output of the compilation would yield the .class file. ( Example.class )

Run the program

In next step, we can execute the class file with java command as shown in the picture. ( /> java Example )

 


Please note that when we execute the class file, we do not require the .class extension as shown in the above command.

In case, you are beginner learning java automation, We suggest you to learn Java coding a few Java programs without IDE. However, there are lot of benefits of Integrated development approach. IDEs provide the comfort of assisting you as you edit the code, with all possible methods and syntax.

 

Java Tutorial on this website: https://www.testingdocs.com/java-tutorial/

For more information on Java, visit the official website :

https://www.oracle.com/in/java/

Exit mobile version