How to compile and run a Java program

1. Download and install Java SE Development Kit  (JDK)


To write and run a Java program, first you need to install a software which is called Java SE Development Kit (or JDK ) - [SE means Standard Edition] .

Accept License Agreement  and  then Download - Java SE Development Kit 

you can download and install according to your operating system .
                     
Knowledge:-

The Java Development Kit (JDK) is a software development environment used for developing Java applications and applets. The JDK includes tools useful for testing programs written in the Java programming language and running on the Java platform.


The Java Development Kit (JDK) files  includes the Java Runtime Environment (JRE).

JRE(Java Runtime Environment) is the core of the Java platform that enables to run Java programs on your computer. It is a set of software tools for development of Java applications. The JRE includes JVM(Java Virtual Machine) that runs Java programs by translating from byte code to platform-dependent code and executes them .

javac.exe: is Java compiler that It turns your .Java text files into machine code(byte code).
java.exe: is the Java Virtual Machine launcher that executes byte code.



2. Open Notepad and write a java program

simple java program 

public class Hello {
                public static void main(String[] args) {
                System.out.println("Hello world ");
                }
}
Create a new folder in your c- drive and save this program as Hello.java to new folder in your C - drive.

3.Open command prompt (admin) and run the program.

open command prompt and type - cd\new  then press enter
next type - javac Hello.java    then press enter
next type - java Hello                 then press enter

now you will see the output of the program " Hello world "









Comments

Post a Comment