Written by Sai Sandeep Thota on June 26, 2013 in How to > Java > Programming

How to execute Java Programs


Get our Latest updates delivered to your mailbox!

Java is one of the most powerful Programming Languages available on the Planet. It is a pure Object Oriented Programming Language. You will require Java Development Kit (JDK) to be installed on your Computer in order to execute them. First you will need to download JDK. Download it from here. You need to accept the terms and download the file depending on your Operating system and Processor.

I have written a step-by-step process for installation and execution which might look lengthy but it is very easy to perform. You can follow this procedure in case if you are experiencing “javac is not recognized as an internal or external command, operable program or batch file.

How to Execute Java Program

#0. Download the JDK.
#1. Install the downloaded setup file in your desired directory.
#2. Right click on Computer and choose Properties.
#2.1. In the System Properties, on the left pane you can find Advanced System Settings, click on it.
#2.2. Head to Advanced tab and select Environment Variables.
#2.3. In the Environment Variables dialog box, you can find System variables. Search for Path variable in it and click on Edit.
#2.4. Add this Path at the starting of it C:\Program Files\Java\jdk1.7.0_25\bin; (including semi-colon) and click OK for three times. (Paste the path of your Java bin directory, in-case if you have changed your installation directory)
#3. Done. You are ready to go now. Open Command Prompt (Start > Run > cmd).
#4. Now say you have a Java Program to be executed. You need to use the following syntax: javac ProgramName.java and then java ProgramName

You can also refer the Video tutorial below:

Follow us on Youtube.

We have executed an example program, just take a look at the screenshot below:

Source code for the Hello World Java Program:

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

You can check Java version by using the command: java -version.

{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: