Step1:
Create a directory named Java Project Modules in your D: drive. We will use folder to store all java programmes that we develop in future.
Step2:
Open Notepad by accessing:
Start -> Programs -> Accessories -> Notepad
Step3:
Type the following code in BLUE in the notepad:
class SampleProgramme {
public static void main (String[] args) {
System.out.println("This is my first Java programme !!");
}
}
Note: This is just a sample programme to test the system, please do not worry about it as of no. We will have a look at this in future sections of this course.
Step4:
Click on File -> Save and in the Save Window navigate to Java Project Modules in your D: drive and type the filename as SampleProgramme.java and click on save.
Now the above programme is saved as SampleProgramme.java file in Java project Modules folder in your D: drive.
Step5:
Open command prompt and type D: and hit Enter. Now you will be in your D: drive in the command prompt.
C:Documents and Settings
enugopa>d: <Hit Enter>
Step6:
Now type cd Java Project Modules and hit enter which will place you in the Java Project Modules directory in D: drive.
D:>cd Java Project Modules <Hit Enter>
Step7:
We have the source file ready in Java Project Modules folder in D: drive which we have to compile now, to do this follow below instructions:
In command prompt type javac SampleProgramme.java
D:Java Project Modules>javac SampleProgramme.java <Hit Enter>
You should get the below prompt:
D:Java Project Modules>
Note: If you encounter a error which reads “'javac' is not recognized as an internal or external command, operable program or batch file” then the environment variable path is not set and we are required to set it now.
Don’t worry, its easy, all we have to do now is to set the path of the directory in which we have installed JDK. We use the following command to set the path:
set PATH=%PATH%;C:Program FilesJavajdk1.6.0_16in
The path in RED is the same path as our jdk installation where javac.exe is stored. In this case it will be stored in the bin folder inside our JDK installation. The path will be same as above if you have followed the procedure exactly as mentioned earlier, if not please type in the relevant path in which you have installed JDK.
Type the above command at command prompt and hit enter.
D:Java Project Modules>set PATH=%PATH%;C:ProgramFilesJavajdk1.6.0_16in <Hit Enter>
Now we have set the Path right and we shouldn’t get any error when we compile our sample programme. Type the below command to compile our programme:
D:Java Project Modules>javac SampleProgramme.java <Hit Enter>
You should get the below prompt:
D:Java Project Modules>
still i face the above error, please replay me soon
Feb 11, 2010