First Java Program | Hello World
From today onwards we are going to start about the world’s top trending language JAVA. On the very first day, we are going to see the basic implementation of java code the first code usually written in Java in the simple First Java Program | Hello World program.
How to write a First Java Program | Hello World?
//a hello world program in JAVA
public class Hello;
public static void main(String args)
- Open your IDE (Eclipse, NetBeans etc) write the above program and run
- You will get the output as “Hello World”
In case of not using an IDE
- Write the above program on your notepad.
- Save the file as Hello.java in any of the drives (let us suppose its D drive).
- Now open your command prompt and type: ‘javac Hello.java’ and press enter.
- If there is no error the command prompt will take you to the next line.
- Now, type: ‘java Hello’ to run your program.
- You will get the output on the window as ‘Hello world’.
NOTE:- For fast and efficient working use any of the IDE, I suggest to use eclipse.
Key points to note:-
- Java is a case-sensitive language so ‘A’ and ‘a’ does matter a lot in it.
- Every java program needs a class to run so making a class is necessary.
- The class name always starts with a capital letter followed by the small.
- All the classes start with the capital letter. Example- String, System etc(Will deeply discuss in next session).
- In java there is no need to write a comment by default java creates a Javadoc file in which all the comments are written and every use of every variable is shown.
Some Brief Description about JAVA:-
JAVA was developed by James Gosling and his colleagues at Sun Microsystems in the 1990s. The term java came when James Gosling and his team members created an idea to develop a language which can be better than other of the languages and can overcome the problems faced during using other languages this thought was struck in their mind while having a cup of coffee on JAVA island(the island where worlds best coffee is served) that is why the symbol of the Java language is a ‘saucer cup’. The name JAVA was the second name at first it was known by the name ‘OAK’.
Java is an object-oriented programming language and it uses both an interpreter and a compiler too. It was developed with the same syntax as another language like C++ has so that the programmer need not learn the language spending much of their time. The first public implementation of JAVA language was JAVA 1.0 in 1995.
The JAVA made the programming a bit easy its capability to ‘compile once and run anywhere’ shortened the distance between the various operating systems. A JAVA code needs to be compiled once and can be run on any platform thus, making it platform independent.
* In the next session we will see the features of java and how Java was better than other of the languages