Page 223 - IT-802_class_12
P. 223
Fundamentals oF 3
Java Programming
In this unit, you’ll learn how to create and run Java programs. However, before you start, you need
to understand what a program is. A computer program is a set of instructions given to a computer to
perform a particular task. The instructions show what and how the computer should do it. Programming
is the preparation and creation of computer programs. Programmers write programs using high-level
programming languages such as Java, C ++, Python, Ruby, and Scala. Computers, on the other hand, only
know their own language, the so-called “machine language”. As a result, a compiler is needed to translate
high-level program code into computer-understandable machine language code. After the program is
created, the machine code can be run on the computer where it was compiled such as Windows. If the
program is to be run on a different platform, such as Mac, it must first be compiled for that platform before
being run.
3.1 IntroductIon to Java
Java is a widely used high-level programming language used to develop a variety of computer programs such
as database applications, desktop applications, web-based apps, mobile applications, and games. Instead of
converting Java code to machine language code, the Java compiler translates it into Java bytecode (a highly
optimized set of instructions). When bytecode (also known as a Java class file) runs on your computer, it is
converted to machine code by a Java interpreter called the Java Virtual Machine (JVM). The advantage of this
approach is that once the Java program is converted to bytecode, it can run on any platform (Windows, Linux,
Mac, etc.). With the help of the JVM, Java programs are considered platform-independent and portable.
Writing a Java program (compiling code into bytecode) requires a text editor (to write the code) and a Java
compiler. There are many Java integrated development environments (IDEs) on the market, including text
editors and Java compilers, making it much easier to create, compile, and run Java applications. Most of
these can be downloaded for free from the internet. To build a Java app, use the open-source and free Java
NetBeans IDE.
3.1.1 Writing a Simple Java Program
Let us write a simple Java program that displays Hello World! messages on the screen. Since this is the first
Java program, you need to set up a programming environment. To do so , follow the steps given below:
1 To start Net Beans, Double-click the Net Beans icon on your desktop. The Net Beans IDE will open.
Fundamentals of Java Programming 221

