JAVA.
Are you beginner? Wanted to known how java program works. How and where to type program? How to execute java program. Learn the following carefully and completely to understand.
Let us write and execute simple program to print HELLO WORLD. For that, first install jdk and keep java environment ready.
There are only 3 main process to execute java program.
- Create the program.
- Compile the program.
- Run the program.
01.CREATE THE PROGRAM.
This the process we create source code which is in the main part of program executing
There are 2 steps to create source code.
1.Write the program.
This is the first step we should write our program. We can type our program in any text editor. Here, i ll be using Notepad.
2.Save the program.
After typing the program save(ctrl+s) the program with the class name.java extension. We must and should save it with class name. Remember it is case sensitive. If class name is capital letter, save the program in capital letters
example:
If your type class hello, you should save it with hello.java
Here. my class name is welcome, so i save as welcome.java. i save in a folder named javapro in desktop.
02. Compile the program.
This is the process to translate source
code, the program we write into an intermediate code called byte code (set
of instruction in 1,0)
- we should open command prompt. (windows log+R, type cmd, and OK.)
- you should change your path to where you saved the program. use the command cd pathname.
Here, i set my path first to desktop and again folder name javapro on the desktop where i saved the program.
- using the command javac classname.java we can compile the program.
Here, as my class name is welcome i type javac welcome.java and press enter. If any error it will indicate us, so that we go back to notepad and correct and save again.
- you can also see the complied file in your folder.
03. Run the program.
This is the process to execute the program. It translate byte-code to machine understandable language, Finally we get the output to the program.
Using the command java classname we can execute the program.
Here, as my class name is welcome i type java welcome and press enter, thus it gives the output.







Comments
Post a Comment