Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Monday, July 23, 2012

CJ-1 : Welcome Program-Consol Application


For a complete list, click JAVA

Refer Introduction to JAVA before going through your first program.

And for theory part , refer "Some Theory Part in JAVA"

=========================================================================
class firstprogram
{
public static void main(String args[ ])
{
System.out.println("Hai...Welcome...");
}
}
=========================================================================
  • Here, firstprogram is the program name.(See, class firstprogram ).The name after declaring the class , is the program name.We have to use the same name , while saving.
  • Also note the capital letters of the words String and System. They are case sensitive.
Type this program in NOTEPAD.


Then , save the program in the same folder , in which the JAVA software is installed.
Here, I installed the JAVA in C disk , jdk 1.3 is the version and bin is the directory.
So , the path is C:\jdk1.3\bin .
(Note the path of the JAVA of your computer.So dont blindly follow the path I described :)


Note the path in above picture.
And it saved as firstprogram.java .

Next, open DOS .


Choose the path in which JAVA is installed..
To do this , follow the steps given.
  1. Type cd\ and press entre . Then we get C:\>
  2. Now choose the directory in which JAVA is installed. Here , my path is jdk 1.3\bin. So, type cd jdk1.3\bin .Then we get , C:\jdk1.3\bin>
  3. Now , compile the program , by typing, javac followed by program name. Here, our program name is firstprogram . Dont forget to put the extension .JAVA  . That is we have to type , javac firstprogram.java
  4. Then Run the program by typing , java followed by program name . That is , java firstprogram.
Then we get the result : Hai...Welcome...
 See the picture below : 



(You can save the JAVA programs in any of the Directory you want , but you havr to give the JAVA installed directory thereafter , using the path command.That is ,

  1. First choose the program directory in DOS prompt.
  2. Then choose the JAVA installed directory , followed by path command.
That is , after giving the location of your program path , type : 
path jdk1.3\bin>

Then compile and run the program.

How to use DOS platform to type\save\edit JAVA:

  1. Type cd\ and press entre . Then we get C:\>
  2. Now choose the directory in which JAVA is installed. Here , my path is jdk 1.3\bin. So, type cd jdk1.3\bin .Then we get , C:\jdk1.3\bin>
  3. Now type , edit followed by the program name.java ( Here, edit firstprogram.java )
Then we can see ;

We can edit the same NOTEPAD program in DOS prompt too...

If we give a new name , then we can type new program in that DOS prompt, then SAVE it in the JAVA directory as told before .

File--> Exit will return to the normal DOS prompt.

No comments: