Friday, 3 June 2022

1. Introduction to Java


Java

Java is a programming language.

What is a language?

Language is a mode of communication, used to share ideas, opinions, and information with one another.

For example, there are two people John and Joe. To talk with each other or to share their thoughts or ideas or information they need something that is language. By using language they can communicate with each other. That language should be understandable by both John and Joe.

English==== Language ==== Communication Language === Share Information.

Here English is a language.

Which type of language?

It's a communication language.

Why it is used?

Communication Language ==== We can provide communication between persons to share information or ideas.

Now a person wants to learn English

----------------------------------------------

Being an English learner person should follow grammar.

Grammar ==== Collection of rules and syntaxes.

In the same way, coming to java

Java ==== Language ==== Programming Language ==== Person to Physical device ( computer), to develop software.

Here java is a language.

Which type of language?

Java is a programming language.

Why programming language is used?

Programming language is used for communication between persons and computers

The programmer wants to learn java

-------------------------------------------

Being java learners we should follow java rules, regulations, and syntaxes

Programming Language ==== Collection of Rules + Syntaxes + Regulations

Now, what is programming?

program is a set of rules to perform a specific task. 

Programming language is used by the programmer to communicate with the computer.

The computer only knows binary language means 0's and 1's because internally computer is built on top of a microprocessor that understands only 0's and 1's, that's why the computer only understands the binary language/ machine language.

But humans don't understand binary language so to communicate with humans with computers we need a translator.

What is a Translator?

A translator is a built-in software that converts human-readable language to binary language/machine language and binary language/machine language to human-readable language.

What is Java

  • Java is an object-oriented programming language used in distributed environments on the internet.
  • High-level programming language
  • Easy to read and understand
  • Simple and easy to use

Background

Java is the most popular language created in 1991, publicly released by 1995

Developed by James Gosling at Sun Microsystems

Java was later acquired by Oracle

The motto is “Write once and run anywhere” (WORA). This means that compiled Java code will run on all java compatible platforms without the need for recompilation.

The first name is ‘Oak’ because of the Oak tree outside Gosling’s office. Later changed to Green then to Java Coffee, he loves the coffee from Indonesia and shortened it to Java in 1995.

Usage

  • ·       Web applications
  • ·        Mobile applications
  • ·        Game development
  • ·        Embedded systems
  • ·        Desktop applications
  • ·        Develop software
  • ·        Mobile devices
  • ·        Electronic devices

§  Televisions

§  Air conditioners

§  Washing machines

  • ·        Online registration forms
  • ·        Banking apps
  • ·        Online shopping apps

Features of java



Editions in Java

There are three editions in Java. Programmers can learn any of these editions based on the application they want to make. 

  • Java Standard Edition - Contains core libraries, like java. lang, java. util, etc. 
  • Java Enterprise Edition - Includes Java APIs, like JMS, EJB, JSPs/servlets, etc.
  • Java Micro Edition - This edition is used to program Java in cell phones, set-top boxes, handhelds, and so on. 

The most widely used edition in Java is Java SE (Standard Edition). Java SE encompasses the basics of Java—most applications require Standard Edition. 

How a java program run


 

  1. Write a java program
  2. Save the java program as a .java file
  3. Compile the .java file with the help of the java compiler
  4. Once the program is compiled the compiler is going to generate another file called the .class file
  5. .class file is also known as bytecode file
  6. This bytecode file can run on any platform either Windows or Linux or macOS.

Java Program Standard Steps

Real time approach:

Assume that we have a subject in graduation called Environmental studies. Imagine a university called JNTUH  is going to prepare an ES question paper. Once done with the question paper they are going to distribute it to the corresponding colleges. Then the students need to write the exam in a booklet which consists of some rules and guidelines like it contains only 32 papers no additional will be provided, use the only blue pen, don't use the red or green pen like this some guidelines are there.

Once writing the exam is done the answer sheet should be validated or correction process. Validation is the process of checking the answer sheet whether the answers are correct or not and following rules and regulations or not. This process is done by JNTU Faculty.

Finally, the university executes the results of all the students. Look at the following approach

Semester Exams

Environmental Studies ===== >  JNTUH

1. Write the exam =====> Students

    Booklet

    Rules and Guidelines

2. Validation / Correction Process =====> JNTU Faculty

    2.1. PASS

    2.2. FAIL

3. Execute the results =====> JNTUH

Three standard steps to write a program in java:

In the same way, Java is a programming language created by Sun Microsystems Later it is handover to Oracle.

JAVA =====> Sun Micro Systems =====> Oracle

1. Write a program =====> Programmer

     notepad / notepad++ / editplus / editplus++ / IDE's Eclipse or Visual Studio or Netbeans

    Rules, Regulations and Syntaxes

    .java extension

After completion of a program, we need to save that program by using the .java extension.

Example:

Filename.java

product.java

2. Validation / Compilation =====> Compiler

    2.1. ERRORS

    2.2. PASS

Now there are two cases:

If there are errors in the program .class file is not generated. If there are no errors in the program .class file will be generated.

Case 1: There is no errors =====> .class file (Binary/Machine/0's and 1's) is                                                                       generated

Case 2: Errors =====> .class file is not generated

After the completion of java program by using compiler we will compile the program.

A compiler is a software that converts the source code to a class file that is the binary language of 0s and 1s.

3. Execute the program =====> JVM ( Java Virtual Machine )

    .class file is generated

JVM executes the .class file and generates the output.

Anatomy of java

JDK: Java development kit, it is a super set of JRE and is a software development environment used to develop java applications and applets.

Once the JDK has been installed it will provide a lot of other components like JRE (Java Runtime Environment), JVM (Java Virtual Machine), class libraries, and other libraries.

Write and compile the program by using the compiler provided by JDK.

Once the program is compiled .class file will be generated.

JRE: Run the .class file using JRE

JRE will run and execute the .class file with the help of three components such as JVM, class libraries, and other libraries.

JVM: JVM is a virtual environment inside which the programs will run. It is platform-independent, it loads the java code, validates the code, and executes the code.

To run the program how does it achieve this environment?

For achieving this virtual machine environment, it would need some runtime libraries, that are provided by this class libraries.

Installing Java

Open the browser and type JDK java download

Click on oracle.com

Select the appropriate OS and download

Install JDK

To check whether JDK is successfully installed or not:

Open cmd

Type java -version

Installing Eclipse

Open browser and type eclipse download

Click on eclipse.org

Click on get eclipse IDE and download it

Install and launch

True or False Questions

1. Compiler is always going to compile or execute .java files

    True

2. Compiler always generates .class files

    False

Because if a program has errors it will not generate a .class file

3. Compiler is always going to generate the .class files if and only if it will follow all the java rules regulations and syntaxes.

    True

4. JVM always executes either .java or .class files

    False

5. Compiler always executes .class files

    False

check your knowledge

I hope you have learned something new today!

Now it's time to check your knowledge!!

Let's answer the below queries

Write answers to the following questions in the comments section

  1. What is java?
  2. What is JDK?
  3. What are the applications/uses of java?
  4. What is a language?
  5. What is a translator?
  6. What is a program?
  7. Who invented java and in which year?
  8. What are the features of java?
  9. Why java is named like that?
  10. How many standards are there in java and what are those?
  11. How many standard steps in java and explain it in your words?
  12. What is JVM, JRE and explain in brief?
  13. Installation steps of Java and Eclipse?
  14. What is .class file and when it will generate(include cases)?
  15. What is the extension of java file?
If you are struggling somewhere to answer the above questions please review the post once again and try it.

😊HAPPY LEARNING👍
👉Please Subscribe, share, follow and comment🙏💓

THANKING YOU ALL


No comments:

Post a Comment

4. Main method in Java

Main method In order to write a program in java, we need to follow 3 standard steps Write a program Validate/compile Execute Examp...