Step by Step Guidelines to Install Java, Set Path and Run First Java Program

ADMEC Multimedia > Web Development > Step by Step Guidelines to Install Java, Set Path and Run First Java Program

If you start to learn Java program as a beginner and wish to learn Java then below mentioned points are important for you. Throughout this blog you will learn fundamental concepts and steps which are necessary for every Java beginner:

  1. How to install Java in your system
  2. How to set path in your system to run your first Java program
  3. How to write first Java program
  4. How to run your first program in Command Prompt after saving your program in desktop
  5. How to run your first program in Command Prompt after saving your program in another drive

Downloading and Installation of Java:

To run Java, first of all you have to install software called Java SE development kit(or JDK).

JDK contains:

  • JRE(Java Runtime Environment):JRE is main of Java platform which create environment to run Java programs on your computer. It includes JVM (Java Virtual Machine) which runs Java programs by converting source code to bytecode to platform-dependent code. and executes the program.
  • Libraries and tools that support Java development

You can download latest Java version after clicking below mentioned link:

http://www.oracle.com/technetwork/Java/Javase/downloads/jdk7-downloads-1880260.html

or Java with Netbeans: http://www.oracle.com/us/technologies/Java/jdk-7-netbeans-download-432126.html

After clicking above link you have to “accept license agreement” and choose latest version, according to your system configurations.

After downloading the software, run it to install JDK and follow steps:

After Successfully installation of Java you can see directory like: C:\Program Files\Java\jdk1.8.0_73

How to check wheter Java installation was successful or not:

  • For this open command prompt (using Window+ R)
  • And type there Java -version(as shown in fig below)

It shows version of the JRE, ex; 1.8.0_73… Congratulations!!!

Now you are able to run Java first program

Set path in your system to run first Java program:

1. Go to window and choose computer:

2. After selecting computer click right side button of your mouse and Click on properties:

3. Then Click advanced system settings:

4. Select advanced option on top and click on environment variable button as shown in fig:

5. After clicking on environment variable button a pop up will be open where you have to click on new button as shown in below fig where :

6. After click on new button a pop appear where you have to fill:

Variable name: Path

Variable Value: C:\Program Files\Java\jdk1.8.0_73\bin

  7. After inserting variable name and variable value click three times OK OK OK….

Java First Program

  1. You can write java program using notepad, notepad++ or netbeans etc.
  2. After writing program you must have save the file (either on desktop or drive )with class name, which you have written in program:

EXAMPLE:

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

Program Output:

Hello ADMEC

      3. Save above program as hello.java

Steps to run program after saving on desktop:

      4. Open cmd(Window+R)

      5. Write cd desktop   

    6. For compilation of program write javac hello.java

  • when your program compile successefully, another file is generated on your desktop and i.e will class file.

      7. For Output:

  • write java hello , now it’s ready to run yor first java program and output of above program will be Hello ADMEC

Steps to run program after saving program in D or E drive:

  1. Create a folder either in D drive or E drive (Ex: Java Program)

Ex:

Computer-> Local Disk(D:)-> Java Program

  1. Write program
  2. Save the program under Java Program
  3. Open cmd(Window+R)
  • Write first: D:
  • cd Java Program
  1. For compilation of program write javac hello.java
  2. For Output:
  3. write java hello , now it’s ready to run your first java program and output of above program will be Hello ADMEC

Please leave your feedbacks or doubts in comments below if any.

Leave a Reply

Related Posts

Copy link
Powered by Social Snap