Lab1: JDK Installation Instructions

Java is a programming language and computing platform first released by Sun Microsystems in 1995. There are lots of applications and websites that will not work unless you have Java installed, and more are created every day. Java is fast, secure, and reliable. From laptops to data centers, game consoles to scientific supercomputers, cell phones to the Internet, Java is everywhere!

Lab Objective: Configuration to run Java app

Step1: To run the JDK installer

  • Start the JDK 11 installer by double-clicking the installer’s icon or file name in the download location.
  • Follow the instructions provided by the installation wizard.

Step2: Setting the PATH Environment Variable

  • It is useful to set the PATH variable permanently for JDK 11 so that it is persistent after rebooting.
  • If you do not set the PATH variable, then you must specify the full path to the executable file every time that you run it. For example: C:> “C:\Program Files\Java\jdk-11\bin\javac” MyClass.java

Step3: To set the PATH variable permanently, add the full path of the jdk-11\bin directory to the PATH variable

Select Control Panel and then System. Click Advanced and then Environment Variables. Add the location of the bin folder of the JDK installation to the PATH variable in System Variables.

Note: The following is a typical value for the PATH variable: "C:\Program Files\Java\jdk-11\bin"

How to check if java is installed ?

  • First, let’s open a command window or terminal and enter:

    • javac -version

    • java -version

If you are getting output like this means you are ready to develop application in java

Structure of Java

class India{
	
	public static void main(String mumbai\[\]){
		

	}
	
}

Above given snippet is the structure of java means you have to write as it is, except for ‘India’ and ‘mumbai’ meaning you can replace India and mumbai with any valid name.

Hello World application in java

Open any text editor and write java code

class Greeting{
	public static void main(String vada\[\]){
		
		System.out.println("Hello World");
		
	}
}
  • It is a convention to save the file name as the class name with ‘.java’ extension, for example Greeting.java
  • To compile the java program
    • Use java compiler which is: javac <file name>
  • To run the java program
    • use java interpreter which is: java <class name>

Output

F:\\coreJAVA\\image>javac Greeting.java

F:\\coreJAVA\\image>java Greeting
Hello World

F:\\coreJAVA\\image>

System.out.println() is the method to print message on console