DEV Community

Cover image for Getting started with programming in Java
Kumar Sanskar
Kumar Sanskar

Posted on

Getting started with programming in Java

Well, it's day 3 of my learning Java journey and today we will move ahead in that by learning some components and how to write and compile our first program in Java.

  • In order to run and make programs in Java on your machine you needs to have something called as JDK which stands for Java Development Kit and can be installed from the respective website of oracle, you can also install its open sourced counter-part OpenJDK if you want to and YouTube as well as Google are always ready to help you in doing so, but with some advanced IDE's like IntelliJ you don't need to worry for that as they do it automatically.

  • JDK consists of :-

    • JRE (Java Runtime Environment)
    • JVM (Java Virtual Machine)
    • Java Compiler(javac)
    • Libraries
    • Development tools.
  • JDK include JRE and other tool to develop and run programs.

  • JRE includes JVM and the standard libraries.

  • JVM executes the Byte-code.

  • Compilation Process of a Java Program:-

    • this process is generally happens inside of JVM.

Source Code(*.java file) ----> given to javac compiler -----> Byte Code(.class file) -----> given to JVM ------->Native Machine code(binary code)

Now we come to final part of the blog that is writing and compiling our first Java program:-

//package information
package.codes.main;

//name of the class "Main" - executable class
public class Main{
    // name of the method "main" - executable method
    public static void main(String[] args){
        // statement to print out to console or display
        System.out.println("Hello, World!");
    }
}
Enter fullscreen mode Exit fullscreen mode

I am assuming that with a prior knowledge of computer and IDE's everyone would be able to compile and check the output of the above program, also the line containing '//' are comments used to make it clear to a new person so as to make them understand what each line does in this program and won't be visible in the output.

Let's catch up in another post tomorrow, till then keep learning keep growing also do let me know of any suggestion and improvements in the comments below.

Top comments (0)