Learn How to Write First Java Program? This tutorial I will teach you how you can write your first Java Program? We will write first program using any text editor and then run it in the command prompt.
This tutorial explains you How to Write Your First Java Program and then easily run in windows command prompt?
In the previous section we have explained you "How to install the JDK on windows computer?" and in this section I will teach you how to create your first Java program, compile the program and run it in the command prompt.
You can use any version of JDK (above 1.5) to run this example code. But I have used the JDK 8, which is the latest version of JDK for compiling and executing the Java program.
This is the series of Java Tutorials for beginners where we are first going to teach you to write first Java program. Devmanuals.com have also made a video instruction for learn this program very easily.
The video instruction of this program is also attached in this page which you can find below in this page.
This is the first program in Java for starting the programming in Java and it involves the writing, compiling then running the program. You will learn how to create first program in Java and then run in the command prompt.
Here is the video instruction of writing the first Java Program:
Step 1: Create Hello World program
For creating the program you can use any of the text editor and save as Java file. Here is the complete code of the Hello World Program in Java:
//http://www.devmanuals.com public class FirstExample{ public static void main(String []args){ System.out.println("Welcome to devmanuals.com"); } }
Copy above code and then it as "FirstExample.java", while saving the file also include the double quotes other wise file might will be saved as .text extension and compiler will give file not found exception. Here is the screen shot of the code in the text editor:
Step 2: Compile the file.
Go to the directory where you have saved the "FirstExample.java" and use the command "javac FirstExample.java" without quote as shown below:
Then try the dir command to find out the class file created, in the above screen shot you can see the class file "FirstExample.class" which is created by the Java compiler.
Step 3: Run the program
To run the program issue the command "java FirstExample" on the console. Following screen shot is the output of the command.
So, today you created your first Java program. Check more tutorials of Core Java at our Java Programming tutorials index page.
[ 0 ] Comments