How to run java program
Run and Compile java code
Write the Java code in a text editor or an integrated development environment (IDE) such as Eclipse, IntelliJ, or NetBeans.
Note:(if you are new programmer and bigger, I suggest to start with notepad)
Example program:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
Save Save the file with a .java extension. For example, if your program is named HelloWorld, you should save it as HelloWorld.java.
Open a command prompt (Windows) or terminal (Mac/Linux) and navigate to the directory where your Java file is located using the cd command. For example, if your file is located in the Desktop directory, you can navigate to it using the following command:
Compile the Java program by typing the following command:
This will create a .class file that contains the compiled bytecode of your program.
Run the Java program by typing the following command:
This will execute the compiled bytecode and run your program
This will execute the compiled bytecode and run your program.
Congratulations! You have successfully compiled and run a Java.
Note: Latest java jdk's are supported that you run and compile program by just this command : java programName.java
Post a Comment