Java introduction notes
Java introduction notes
The features and strengths of Java have made it suitable for applications
throughout the history of Internet, and it continues to do so even for
modern applications.
In Java, the program (source code) written by the programmer gets compiled
and converted into byte code (compiled code) by the Java compiler.
All the byte codes required for the program are then given to the interpreter.
The interpreter reads the byte code line by line, converts it to binary form, also
called as machine language or binary language, and then executes it.
This process requires some support and an environment for the execution to
happen. JDK (Java Development Kit) helps in this for execution of a Java
program. It provides library support and Java Runtime Environment (JRE),
the environment for developing and executing Java based applications and
programs.
java installation
Youwill now start the journey of learning programming using Java. To start
writing programs in Java, you need to first install Java.
Please follow the below steps to check whether Java is installed on your
computer.
Open command prompt and check if Java is installed in your computer using
the following command
1. java -version
If Java is installed on your computer, you will get a message about the version
installed on the command prompt window as shown below:
After making sure that you have Java installed in your computer, you
then need an IDE (Integrated Development Environment) to code Java
programs.
1. class Welcome {
2. public static void main(String[] args) {
3. System.out.println("Hello World! Welcome to
Java Programming!");
4. }
5. }
The steps given below will enable you to use Eclipse to write any program.
Step 7: Right-click on the package, select New -> Class. This will create a
new .java file where you can write your program.
Step 8: Enter the name of the class as Welcome and click on Finish.
Step 9: The .java file will open in the editor.
Copy the code given below in the .java file and save the file.
By default, Eclipse will automatically compile the .java file into a .class
file (byte code) when the file is saved.
1. package demo;
2. public class Welcome {
3. public static void main(String[] args) {
4. System.out.println("Hello World! Welcome to
Java Programming");
5. }
6. }
7.
Step 10: To execute the program, right-click on the .java file, select Run As ->
Java Application.
.
Execution of java programme