Environment Setup in java

How to install JDK or Environment setup to start Java development. How to write the first Java project.

After the Java Introduction. Here we are going to set up the Java environment and write a Java program to print “Hello World”.

Environment Setup in java

The following are the steps to install JDK in your machine.

Download the latest version of java(JDK) to installs it in your machine by just clicking the link Download JDK or you can visit the official site of Oracle.

Accept the license agreement, choose your operating system and download the JDK

When you click on the downloaded file and automatically one dialog box will appear which asks the admin whether to install or not. Click the yes button, installation starts automatically.

Click on next to go further in the installation process.

Automatically this wizard installs all the files on your computer. Once the installation completed, you may click the Close button.

JDK Installation is completed. Now your machine is ready to write the first program in Java. For example, Here we are going to print “Hello World” message in Java.

How to print a statement or message in java?

To print anything in java you need to learn the statement i.e, System.out.println(“Enter your text”); in the double inverted commas you can write what you want to print, but remember one thing that Java is statically typed language so you should give extra attention to syntax.

If you are beginner, Initially will suggest to work with notepad and later on will move to some IDE like Netbeans, eclipse or STS tool.

Steps to write “Hello world” program in Java with Notepad

  • Open notepad, write the code given below.
  • Save the file at the desktop(or wherever you want) as same as the class name with extension .java.
  • Open command prompt.
  • Navigate to the saved program file location.
  • Compile the Java program(Javac hello.java).
  • Run Java program(java hello).

Write Java program to print “Hello World”

public class Hello{
  
  public static void main(String args[]) {
    
              System.out.println("Hello World"); 
    
  }
}

Open the command prompt and move the command over where you save the file(In my case it’s Desktop).

Compile Java program: Type javac filename.java, then your file name with extension, to compile the program.

CMD: javac Hello.java

Run Java Program: Type java file name with your file name to run the program.

Cmd: java hello.java

Output: