New Lect1
New Lect1
Lecture 1
• Write once, run anywhere: Because Java applications are compiled into machine-
independent byte codes, they run consistently on any Java platform.
• Distribute software more easily: You can upgrade applets easily from a central
server. Applets take advantage of the feature of allowing new classes to be loaded "on
the fly," without recompiling the entire program.
Java applet: Is a small program that normally is stored on a remote computer that
users connect to via a World Wide Web browser. The remote computer is known as a
Web server. Applets are loaded from a remote computer into the browser, executed in
the browser and discarded when execution completes.
2
Lecturer: Dr. Lahieb Mohammed Al-Yassiry
College of Information Engineering
Department of Computer f Networks Engineering &
Department of Information and Communication Engineering
OOPII(Java), 2nd Class, 2020/2021
1.5.1 Netbeans
NetBeans is an open-source, free Java IDE with a modular architecture. It has a
multi-language editor, debugger, profiler, versioning control, and developer
collaboration. It supports the development of other languages like PHP and C++. It
integrates all the functionality of Java. NetBeans runs on all major operating systems
3
Lecturer: Dr. Lahieb Mohammed Al-Yassiry
College of Information Engineering
Department of Computer f Networks Engineering &
Department of Information and Communication Engineering
OOPII(Java), 2nd Class, 2020/2021
like Windows, Linux, and Mac OS. It is an easy to install IDE and provides skeleton
applications and templates with sample applications as well and let developers save
time by letting them start coding on a skeleton project. so that they don’t have to go
through the process of implementing modules and pre-written code themselves.
Moreover, it is originally a part of the Sun systems has now slipped into the hands of
Oracle. This platform works as a framework for the development of JAVA swing
desktop applications. No additional SDK is required for the NetBeans IDE in JAVA
SE which uses the plugins and platform based applications for developing.
4
Lecturer: Dr. Lahieb Mohammed Al-Yassiry
College of Information Engineering
Department of Computer f Networks Engineering &
Department of Information and Communication Engineering
OOPII(Java), 2nd Class, 2020/2021
1.5.1 Eclipse
Eclipse is an open-source and free IDE with a modular architecture. It is the most
popular Java IDE. It provides support for the development of many languages but it is
mostly focused on Java and C/C++ development. Eclipse is compatible to run on all
types of operating systems like Windows, Linux, and Mac OS. Eclipse also provides
the support for working on documentation and modeling using papyrus and provides
tools for implementation of UML, SysML, OCL etc.
Eclipse is known for its extended support for plugins. It provides the support for users
to make their own Plugin Development Environment or PDE to make plugins. It also
provides customizability, GUI building, reporting etc. Eclipse also has a Standard
Widget Toolkit or SWT, which is used to access and use GUI elements from the
operating system on which the program is being developed. Eclipse also provides
also used to provide android development tools but was ended in 2015.
5
Lecturer: Dr. Lahieb Mohammed Al-Yassiry
College of Information Engineering
Department of Computer f Networks Engineering &
Department of Information and Communication Engineering
OOPII(Java), 2nd Class, 2020/2021
The advantage using the Eclipse is it has a plenty of plugins which are customizable
and versatile. It works in the background compiling code and reports errors as they
come up. Eclipse comes with a lot of features of editing, browsing, refactoring and
debugging for Java server development.
Eclipse is whole of visual containers which offer a set of views of editors. Basically,
it does everything you want your IDE to be and integrates with most of the tools.
Developers choose Eclipse for its ease in use and open source platform. It can be a
little trouble for newbies to work with but steadily it becomes a great experience to
work with it.
6
Lecturer: Dr. Lahieb Mohammed Al-Yassiry
College of Information Engineering
Department of Computer f Networks Engineering &
Department of Information and Communication Engineering
OOPII(Java), 2nd Class, 2020/2021
1.5.3 Intellij
IntelliJ IDEA which is a part of JetBrains is available in both free source and a
commercial edition. Already, it has the Resharper plugin for Visual Studio in C#
development by JetBrains. IntelliJ supports a variety of languages such as Clojure,
Groovy, Scala, Java and many more; it also has features such as advanced
forecasting, code analysis, and smart code completion. It supports PHP, Ruby,
Python, SQL, and ActionScript. Recently, it has launched version 12 which comes
with the new Android UI for Android app development. It allows users to submit
more plugins by using its built-in Swing components and features several user-
written plugins for enterprise edition.
7
Lecturer: Dr. Lahieb Mohammed Al-Yassiry
College of Information Engineering
Department of Computer f Networks Engineering &
Department of Information and Communication Engineering
OOPII(Java), 2nd Class, 2020/2021
8
Lecturer: Dr. Lahieb Mohammed Al-Yassiry
College of Information Engineering
Department of Computer f Networks Engineering &
Department of Information and Communication Engineering
OOPII(Java), 2nd Class, 2020/2021
9
Lecturer: Dr. Lahieb Mohammed Al-Yassiry
College of Information Engineering
Department of Computer f Networks Engineering &
Department of Information and Communication Engineering
OOPII(Java), 2nd Class, 2020/2021
-Class Body
The first left brace {, begins the body of every class declaration. A corresponding
right brace , }, must end each class declaration.
- The parentheses after the identifier main indicate that it’s a program building block
called a method. Java class declarations normally contain one or more methods. For
a Java application, one of the methods must be called main; otherwise, the Java
Virtual Machine (JVM) will not execute the application. Methods perform tasks and
can return information when they complete their tasks.
-System.out
The system.out object—which is predefined for you—is known as the standard
output object. It allows a Java application to display information in the command
window from which it executes.
-System.out.println
11
Lecturer: Dr. Lahieb Mohammed Al-Yassiry
College of Information Engineering
Department of Computer f Networks Engineering &
Department of Information and Communication Engineering
OOPII(Java), 2nd Class, 2020/2021
The next statement calls the println method of the system class and prints the
sentence "welcome to java programming". As with other methods, the arguments to
11
Lecturer: Dr. Lahieb Mohammed Al-Yassiry
College of Information Engineering
Department of Computer f Networks Engineering &
Department of Information and Communication Engineering
OOPII(Java), 2nd Class, 2020/2021
pass to the method are declared between open and close parentheses. Each statement
in Java ends in semicolon:
System.out.println("welcome to java programming ");
The final two lines of welcome1 program are close brackets. The first close bracket
completes the block of code associated with the main() method. The second close
brackets completes the block of code associated with welcome class.
Exmple2:
Example3:
public class Main {
public static void main(String[] args) {
System.out.println("Welcome");
System.out.println("to");
System.out.println("information");
System.out.print("engineering");
} // end method main
} // end class Main
Output:
Welcome
to
information
engineering
12
Lecturer: Dr. Lahieb Mohammed Al-Yassiry