1 - The Java Programming Language
1 - The Java Programming Language
FROM SOURCE CODE TO A RUNNING PROGRAM So, why was Java created again?
- Code of any programming language must be saved into a - So the programs written in it can be run on different devices
file. easily.
- This file contains the source code for the program, and thus - This means that Java programs are very easily portable.
is called a source file. - Portability in programming means that a program can be
Source Code – is the human written code for a program. written on one computer and run on many different ones.
- Java is known as a high-level language. In traditional compiled languages, you must recompile your
program from the source code for every different machine
- A High-Level Programming Language is a language that is you want to run it on.
easily read and written by humans, and is needed to be
translated before a machine can use it. It provided a high - Tedious
level of abstraction from the details of the workings of the - Can run into problems between systems
computer’s hardware
As long as the machine you want to execute the program has
- Most programming by humans is done in high-level a compatible version of the JVM, your Java program can be
languages run on it without recompiling it!
- The source file for a high-level language needs to be If the JVM is correctly installed, there is (almost…) no
translated into a form that a machine can understand problems.
through a process called compilation.
Steps to create and run Java Program:
Compilation - is the process of translating high-level language
1. Write the source code in the Java programming
into machine language for platform-specific languages or
language.
some other intermediate code representation for other
2. Run the source code through the Java Compiler
languages. A program called a compiler does this.
(Interpreter)
Machine Language is a sequence of instructions directly 3. Run the resulting Java Byte Code through the JVM
executed by a processing unit (CPU in most cases). 4. The program executes!
- When you compile Java source code it results in Java Byte
Code, NOT Machine (Specific) Language
Running a compiler successfully on source code results in an
executable file.