Java Compiler

Java Language

The Java language has its own structure, syntax rules, and programming paradigm like any programming language. The Java language’s programming paradigm is based on the concept of OOP, which the language’s features support.

Java Compilation

When you write program for the Java platform, you write source code in .java files and then compile them. The compiler checks your code against the language’s syntax rules, then writes out byte code in .class files. Byte code is a set of instructions targeted to run on a Java virtual machine (JVM). In adding this level of abstraction, the Java compiler differs from other language compilers, which write out instructions suitable for the CPU chipset the program will run on.

Public class MyFirstJavaProgram {

   /* this is my first java program.

    * This will print ‘Hello World’ as the output


Public static void main (String [] args) {

System.out.println (“Hello World”); // prints Hello World



Let’s Folow these steps how to save the file, compile and run the program.

  • Open notepad and add the code as above.
  • Save the file as:
  • Open a command prompt window and go to the directory where you saved the class. Assume its C:\.
  • Type ‘ javac’ and press enter to compile your code. If there are no errors in your code, the command prompt will take you to the next line (Assumption: The path variable is set).
  • Now, type ‘ java MyFirstJavaProgram ‘ to run your program.

You will be able to see ‘ Hello World ‘ printed on the window.

C :\>javac

C :\> java MyFirstJavaProgram

Hello World

Basic Syntax:

About Java programs, it is very important to keep in mind the following points:

Case Sensitivity – Java is case sensitive, which means identifier Helloand hello would have different meaning in Java.

Class Names – For all class names the first letter should be in Upper Case.

If several words are used to form a name of the class, each inner word’s first letter should be in Upper Case.

Example class MyFirstJavaClass

Method Names – All method names should start with a Lower Case letter.

If several words are used to form the name of the method, then each inner word’s first letter should be in Upper Case.

Example public void myMethodName ()

Program File Name – Name of the program file should exactly match the class name.

When saving the file, you should save it using the class name (Remember Java is case sensitive) and append ‘.java’ to the end of the name (if the file name and the class name do not match your program will not compile).

Example: Assume ‘MyFirstJavaProgram’ is the class name. Then the file should be saved as ‘’

Public static void main(String args[]) – Java program processing starts from the main() method which is a mandatory part of every Java program.

If you like this post then please share and visit this post.

Visit us @

Call us @ 98256 18292.

To Know More about Java Course, Computer Classes


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s