As of my experience all programing languages are like mathematic. because for all programs we want to study the syntax for applying each and every code like studying different equations in mathematics for solving problems.
In both programing and mathematic on thing in common is the logic of the user to apply the syntax or equation in correct way for achieving the correct answer/ program.
The logic for the same can only gained by continues practice so we can get into practice section on java
For running java program in our pc we required Java JDK (Java development kit ) in our pc. We can download this for the official site of java.
On the official site select the version and OS according to your pc. Version can be selected as the latest.
After downloading open the downloaded file and complete the installation according to instruction showing.
After completing installation, we want to Set the system variable for java to run the java programs.
After setting the variables we can start java programing.
In most of the cases many will say to use different IDEs for programming. But as beginners using notepad for programming will be the best practice by that you can understand much for it because on IDE's it will show us all the suggestions and error while we are typing the program it will not help us to understand why that happens and debugging by your own will improve your knowledge too.
For wind upping the introduction section I will show you a java program to print something on the screen and I will show our how to run it too. And the remaining portion will be covered on upcoming days.
First java program
Open notepad
Type the program shown as above.
Save the program in any location as you need with an extension .java
example:- FirstProgram.java
The first letter of the name should be capitalized and the name should end with .java extension.
The best practice is to use file name and class name as same for the program. Here in the above program the Class name is A so the best way to save the program is to save it with the name A.java.
After saving the program you can run the program using command prompt. you want to open CMD and go to the directory in which you saved the program.
After that you should use java compiler for converting the java program to runnable form for running the program using JRE .
Command to compile:- javac Filename.java
After compiling the program, we can see an additional file on the directory where the programs saved which is the runnable file for the program.
now we can run the program simply typing java class name (the name of the file created by compiling the program)
Command to run: - java class name