Procedure to develop a JAVA program

0

Procedure to develop a JAVA program.
Step-1: Create a folder to store all your programs. This folder is called the Present Working Directory. Assuming the  folder path as (G:\netlojava\java_prog)

Step-2: Open notepad (start -> All Programs -> Accessories -> Notepad) and type below code


Step-3: Save this file in java_prog folder with name FirstProgram.java
Note: Java file name can be user defined name. It is not always mandatory to save java file name with same class name. If class is declared as "public" then only it is mandatory to save the file with class name. Let us try with different java file name.


Folder Structure

Program development is completed, now let us compile and execute.

Compilation and execution:
Step-4: Compilation
1. Open command prompt.
2. Change Drive and then directory to current working directory to Java_prog folder.
3. Then use javac tool to compile FirstProgram.java file, as show below figure.


Compiler has generated ".class" file successfully for the class JavaProgram in java_prog folder.
Note: Compiler generates ".class" file with the class name not java file name.
Check Java_prog folder for ".class" file name.


Step-5: Execution
Use java tool to execute JavaProgram class bytecodes file, as show below figure.


Compiler Activity:
It takes java file name as its input and generates bytecodes for all classes defined in that java file and stores each class bytecodes in a separate ".class" file with name same as class name.

JVM Activity:
It takes class name as its input and searches for a .class file with the given class name. If it found it reads and loads that .class file bytecodes into JVM, then starts that class logic execution by calling "main" method.


About the author

Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus. Aenean fermentum, eget tincidunt.

0 comments:

Recent Posts