Krivalar Tutorials 
Krivalar Tutorials

Java Basic Program - Hello World

<OOPS concepts

Class >

Java programs are case sensitive. That is, classes, interfaces, variables, keywords or any type names in upper case is not the same as the names in lower case. For Example, Employee is different from employee or EMPLOYEE or eMployee.

Simplest Java Program

One of the simplest java programs is shown below:

public class ClassName{
 public static void main(String s[]){
				"My First Program");

Java File Naming Criteria

Java programs need to be saved in a file with:

Java Class Naming Criteria

In order for java class name to be valid and to compile correctly, the following criteria needs to be satisfied

Java Class Naming Conventions

For Java class names, following conventions are followed in all Java programs and in all libraries but there is nothing that enforces these.

Compiling a simple Java program

We can execute the following from the windows or Unix command line


javac command compiles each of the java classes into a bytecode file with the ".class" extension

Executing a Java class with main() method

We can use the following command to execute a class

java ClassName

java command interprets the java class and runs the main() method defined within the ClassName

main() method

main() method should have the same signature as shown below. Variable name args can be any variable name following the naming rules and conventions

public static void main(
			String args[]){


main method should

You can have main() methods with other signatures but those methods are regular methods and are not a starting point for execution.

< OOPS concepts

Class >