Steps to Compile and Run your first Java program

Steps to Compile and Run your first Java program

Step 1: Open a text editor and write the code as above.
Step 2: Save the file as Hello.java
Step 3: Open command prompt and go to the directory where you saved your first java program assuming it is saved in C:\
Step 4: Type javac Hello.java and press Return(Enter KEY) to compile your code. This command will call the Java Compiler asking it to compile the specified file. If there are no errors in the code the command prompt will take you to the next line.
Step 5: Now type java Hello on command prompt to run your program.
Step 6: You will be able to see Hello world program printed on your command prompt.

Ways to write a Java Program

Following are some of the ways in which a Java program can be written:
Changing the sequence of the modifiers and methods is accepted by Java.
Syntax: static public void main(String as[])
Example:
 
class Hello
{
 static public void main(String as[])
 {
 System.out.println ("Welcome to javasimpleknowledge.blogspot.com");
 }
}
 
Output:
Welcome to javasimpleknowledge.blogspot.com

Post a Comment

0 Comments