Wednesday 24 January 2018

Setting Path in  Java:

In case to java,we have to execute the program in the DOS environment.
DOS which is a command driven operating system.In case of DOS,
every thing is executed as per the command given by the user.

There are so many commands in the DOS , so all the command are categorized into ,
(i) Internal commands
(ii) External commands
(i) Internal commands are those commands which always present in the primary memory.
(ii) External commands are those commands which are present on the secondary memory as files.So, before executing these commands we have to set the path where these commands files are present.
The location is specified using the PATH command.
PATH="C:\windows;c:\windows\system"
So, whenever we give an external command  "MS DOS" will look for that external command related file in the current directory,and if the file corresponding to it is not present in the current directory, then it will search for that files in the directories specified with the path command , so it will first look in c:\windows and then in c:\windows\system.

If the file is not found there then it will give an error message ,
"Bad Command or File Name"
Take the following steps:

(i) Double click on the My Computer icon on the desktop .
This is the image of my computer, where we can select the properties

(ii) In the My Computer window find out where the java software i.e. JDK(JavaDevelopmentKit)  is installed.

(iii) Copy the path including the location of the BIN  directory,
In our case it is ,
        C:\j2sdk1.4.1_03\bin
(iv) Right click on the My  Computer icon present on the desktop.And from the sub menu click on the properties option.

(v) The System Properties dialog box will appears on the screen click on the Advanced Tab.

(vi) Click on the Environment Variables button .

(vii) From the list of the System variables ,select path and click on edit button, And type the java path in following manner

(viii) Now ,close all the dialog boxes by clicking on the ok button.And restart the computer ,so make the path take the effect.
(ix) Now after restarting open MS-DOS prompt,

Start->Run...

Type cmd in the run dialog box
MS-DOS terminal window will appear on the screen

To check java is configured, type javac and press enter.

The help regarding javac command indicated that the java path is perfectly set.
        Now, we have a program with name Sample.java in directory core in d:\
(x) Move to core directory :



(xi) Run the program


No comments:

Post a Comment