Executing Java Programs

We discussed some basic things about java programs in last post, in this post we will discuss about how to execute programs and should do some predefined settings to execute programs too, let’s get started
For executing java programs we need to do set path. We will discuss later about the setting path and now we let start discussion about Editor. Java can be written and executed in ordinary editor itself, we have got many editors but the famous is Eclipse and net beans links to download this editor have been provided previously.
If you use one of the above editor (Eclipse or net beans) ne need to set path and all. If not you must set path to execute java programs. I’ve told many times “set path” But didn’t explain it, let’s see what that is. Set path is done in command prompt (cmd), set path is nothing but saying that editor (ordinary our windows notepad or some other editor) or command prompt to execute the java programs.
Please follow the steps to set java path.
Figure <!–[if supportFields]> SEQ Figure \* ARABIC <![endif]–>2<!–[if supportFields]><![endif]–>     Setting Java path
For setting path, click on the start button->Right click on My Computer-> then select properties.
A window will popup and select the advanced system settings, then your window will look like this.
Figure <!–[if supportFields]> SEQ Figure \* ARABIC <![endif]–>3<!–[if supportFields]><![endif]–>   Right  click on my computer then select advanced system settings
From that select Advanced system setting and then you will get a window like below one.
Figure <!–[if supportFields]> SEQ Figure \* ARABIC <![endif]–>4<!–[if supportFields]><![endif]–> select Environment variables
Once you get above windows select Environment variables, before that you should copy the java installed path in your system. The installed path may like this “c:\Program Files\java\jdk1.6\bin” And provide name as java you can provide name as you like.
Figure <!–[if supportFields]> SEQ Figure \* ARABIC <![endif]–>5<!–[if supportFields]><![endif]–> setting java path
Once you done the above steps you can start typing java programs, open any editor you got installed on your machine. Then type the following program.
Figure <!–[if supportFields]> SEQ Figure \* ARABIC <![endif]–>6<!–[if supportFields]><![endif]–> Sample java programs
In my case I’ve used notepad++ once completed typing save your file in location of your user, in my case “C:\Users\Gopi\java” java is the folder name which I have created for saving java programs. You can give any name to that folder and that folder should present inside your user folder. Hope you understand what I’m saying.
I’ve explained the concepts of above program in previous post. If you have any doubt just refer the following link.
Once you completed all the stuff then goto run in start button or else just type run in search box you will get it. Then type cmd (command prompt ) in run window then click enter..
Figure <!–[if supportFields]> SEQ Figure \* ARABIC <![endif]–>7<!–[if supportFields]><![endif]–> Run Box
In the command prompt type the command as following set path= “paste the location of your java installed path on your machine” press enter then type as javac. Javac is the java compiler which compile the java program. Once it just go to next line then your program doesn’t have any error “SUCCESS” below image will explain you about setting path and executing java programs.
Figure <!–[if supportFields]> SEQ Figure \* ARABIC <![endif]–>8<!–[if supportFields]><![endif]–>  setting path
Figure <!–[if supportFields]> SEQ Figure \* ARABIC <![endif]–>9<!–[if supportFields]><![endif]–> output of above program
Successfully we got the output. Hope you to got the same
Hope this post will help you making understanding of java programs and executing

One thought on “Executing Java Programs

Tell us Your Suggestion

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s