Create First Program
In this section, you will learn to write a simple Java program. For developing a java program you just need a simple text editor like "notepad".
Open the notepad and write your program.
Let's create a class createfirstprogram that will print a message "Welcome to RoseIndia.net" on the console.
Here is the code of createfirstprogram.java file:
Save this program in the specified directory ("C:\Vinod" in this example) with name createfirstprogram.java.
This class contains public, static and void java keywords (these are pre-defined words in java which carries specific meaning).
public keyword specifies the
accessibility issues of a class. Here, It specifies that method can be accessed from anywhere.
Now, you are ready to compile and run this program. Open the command prompt and go to the directory ("C:\vinod" in this example) where your program is saved.
Java uses the "javac" command to compile your program (Type javac createfirstprogram.java) . After compiling successfully, you can run it. Java uses the "java" command to execute your program (Type java createfirstprogram). It will print "Welcome to RoseIndia.net".
Output of program: