Assignment WXGA6101 Individual Project FARAH NAWWAR BIDIN WGA050060 Java - PowerPoint PPT Presentation

1 / 32
About This Presentation
Title:

Assignment WXGA6101 Individual Project FARAH NAWWAR BIDIN WGA050060 Java

Description:

Widely used in mobile application and games development. ... Collection - Java does not require programmers to explicitly free dynamically allocated memory. ... – PowerPoint PPT presentation

Number of Views:161
Avg rating:3.0/5.0
Slides: 33
Provided by: frh
Category:

less

Transcript and Presenter's Notes

Title: Assignment WXGA6101 Individual Project FARAH NAWWAR BIDIN WGA050060 Java


1
Assignment WXGA6101 - Individual ProjectFARAH
NAWWAR BIDINWGA050060Java
2
PART I INTRODUCTION
3
history of language, who designed it and why?
  • Bill Joy is widely believed to have been the
    person to conceive of the idea of a programming
    language that later became Java.
  • Evolved from a language named Oak. Oak was
    developed in the early nineties at Sun
    Microsystems as a platform-independent language
  • Aimed at allowing entertainment appliances such
    as video game consoles and VCRs to communicate.
  • Just as the deals with the set-top box
    manufacturers were falling through, the World
    Wide Web was coming to life.
  • Their focus shifted to the Internet and
    WebRunner, an Oak-enabled browser, was born.
  • Oaks name was changed to Java and WebRunner
    became the HotJava web browser.
  • Widely used in mobile application and games
    development.

4
  • what programming paradigm(s) does it readily
    support?
  • Object oriented, multiplatform and generic.
  • what application areas is it most suited for?
  • World Wide Web Applets
  • Cross-Platform Application Development
  • Other Network Applications

5
  • what are features?  
  • Platform Independence - Java compilers do not
    produce native object code for a particular
    platform but rather byte code instructions for
    the Java Virtual Machine (JVM). Making Java code
    work on a particular platform is then sim ply a
    matter of writing a byte code interpreter to
    simulate a JVM. What this all means is that the
    same compiled byte code will run unmodified on
    any platform that supports Java.
  • Object Orientation - Java is a pure
    object-oriented language. This means that
    everything in a Java program is an object and
    everything is descended from a root object class.

6
  • Rich Standard Library - One of Javas most
    attractive features is its standard library. The
    Java environment includes hundreds of classes and
    methods in six major functional areas.
  • Language Support classes for advanced language
    features such as strings, arrays, threads, and
    exception handling.
  • Utility classes like a random number generator,
    date and time functions, and container classes.
  • Input/output classes to read and write data of
    many types to and from a variety of sources.
  • Networking classes to allow inter-computer
    communications over a local network or the
    Internet.
  • Abstract Window Toolkit for creating
    platform-independent GUI applications.
  • Applet is a class that lets you create Java
    programs that can be downloaded and run on a
    client browser.

7
  • Applet Interface - In addition to being able to
    create stand-alone applications, Java developers
    can create programs that can be downloaded from a
    web page and run on a client browser.
  • Familiar C-like Syntax - One of the factors
    enabling the rapid adoption of Java is the
    similarity of the Java syntax to that of the
    popular C programming language.
  • Garbage Collection - Java does not require
    programmers to explicitly free dynamically
    allocated memory. This makes Java programs easier
    to write and less prone to memory errors.

8
what are the claims made of its security,
portability, efficiency, extensibility
/maintainability?
  • Security
  • The compiler, interpreter, and Java-compatible
    browsers all contain several levels of security
    measures that are designed to reduce the risk of
    security compromise, loss of data and program
    integrity, and damage to system users.
  • Considering the enormous security problems
    associated with executing potentially untrusted
    code in a secure manner and across multiple
    execution environments, Java's security measures
    are far ahead of even those developed to secure
    military systems. C and C do not have any
    intrinsic security capabilities.

9
  • Portability
  • One advantage of Java is that its programs can
    run on any platform without having to be
    recompiled. This is one positive aspect of
    portability.
  • It goes on even further to ensure that there are
    no platform-specific features on the Java
    language specification.
  • For example, in some languages, such as Ada, the
    largest integer varies on different platforms. In
    Java, the size of the integer is the same on
    every platform, as is the behavior of arithmetic.
    Having a fixed size for numbers makes Java
    programs portable.
  • The Java environment itself is portable to new
    hardware and operating systems, and in fact, the
    Java compiler itself is written in Java.

10
  • Efficiency
  • Java is less efficient than Fortran, C, C and
    probably half-a-dozen other languages.
  • When interpreted, Standard Java is about 30-60
    times slower than C.
  • When Java is compiled by a just-in-time compiler
    (jit), it seems to be about 3-6 times slower than
    C. Java compiler technology is improving rapidly,
    but how efficient it can get relative to other
    languages is unclear.
  • .
  • Java's just-in-time performance acceptable for
    prototyping small- to medium-sized problems.
  • However, for large field data examples, we may
    have to re-implement our application in a better
    performing language, after we developed it in
    Java.

11
  • Extensibility/maintainability
  • Java is also an excellent language for
    manipulating XML data.
  • The Java 2 platform provides an
    architecture-neutral means to write
    object-oriented applications that scale well over
    time, have a shorter development cycle and have
    improved maintainability.
  • Java comes with a rich, standard library of
    APIs. This allows developers to leverage a large
    body of pre-existing code modules for effective
    programming.
  • Programs in Java which use standard library
    classes are easier to understand and extend than
    those which rely on complicated, homegrown
    classes.

12
describe the compilation/interpretation/execution
model it uses.
  • Java programs normally go through 5 phases to be
    executed ( edit, compile, load, verify and
    execute).

13
(No Transcript)
14
  • Interpreter
  • An interpreter is needed in order to run Java
    programs. The programs are compiled into Java
    Virtual Machine code called bytecode.
  • The bytecode is machine independent and is able
    to run on any machine that has a Java
    interpreter. Normally, a compiler will translate
    a high-level language program to machine code and
    the code is able to only run on the native
    machine. If the program is run on other machines,
    the program has to be recompiled on the native
    machine.

15
  • JVM
  • This VM sits between the Java program and the
    machine it is running on, offering the program an
    "abstract computer" that executes the Java code
    and guarantees certain behaviors regardless of
    the underlying hardware or software platform.
  • Java compilers turn Java programs not into
    assembly language for a particular machine but
    into a platform-neutral "byte code" that the
    machine-specific VM interprets on the fly.

16
PART II
  • DESCRIPTION OF THE LANGUAGE
  • USING COMPARISON OF VARIOUS LANGUAGES

17
Scalar data objects
Single-valued data types, that can be used for
individual variables, constants, etc
18
Composite objects
Composite objects are several objects and scripts
bundled together exposed to the application as a
single object.
19
Structured objects
A structured data object is a user-defined data
type with elements that are not atomic rather,
they are divisible and can be used either
separately or as a single unit
20
Abstract data types
Abstract data type (ADT) is a specification of a
set of data and the set of operations that can be
performed on the data. Such a data type is
abstract in the sense that it is independent of
various concrete implementations.
21
Active Objects
An active object is an instance of a class with
encapsulated behavior, running one or more
separate threads. (tasks, processes)
22
Below is the comparison of C, C and Java
languages
23
(No Transcript)
24
PART III -
  • FINAL EVALUATION

25
  • 1. Do you have any basis to agree or disagree
    with any claims made of its security,
    portability, efficiency, extensibility/maintainabi
    lity?
  • Yes I agree with all the claims made against its
    security, portability, efficiency,
    extensibility/maintainability.
  • Security Java perform a number of run-time
    checks to detect errors early.
  • Portability Can be run on almost all types of
    OS and machines.
  • Efficiency Less efficient than most languages
    as the compilation process takes time but other
    features (such as suitable and easy to use for
    networking programs RMI socket programming and
    multithreading) seems to attract programmer to
    use Java even it is slow in execution.
  • Extensibility/maintainability Java utilizes
    standard library classes which are easier to
    understand and extend than those which rely
    homegrown classes
  • 2. What aspect of this language did you find most
    difficult to learn/understand?
  • - JDBC(TM) Database Access.
  • - Concurrent programming with threads.
  • - Handling exceptions.
  • - Socket Programming and multithreading

26
  • 3. How would you rate the programming
    environment? compiler/interpreter messages?
  • - Slow but still acceptable and actually it is
    rapidly improving.
  • 4. Would you use this language again and if so
    what for? if not, what would you choose to use
    instead and why?
  • - Yes. In socket programming. One of the
    reasons why I use Java because it is opensource
    and its development tools can be downloaded for
    free from Sun Microsystems website.
  • 5. Design mistakes (in your opinion or the
    opinion of others)? Have they been corrected in
    other languages that were a follow-on. What if
    anything is missing in your opinion?
  • - The slow execution time. I think it cannot be
    called as design mistakes but it is unavoidable
    things as its program purposely designed to be
    compiled into Java Virtual Machine bytecode first
    so that it will enhance the mobility part.
    There is no perfect language to suit the entire
    applications and programmers requirements. It
    depends on the programmers to master the
    language, minimize the defects, optimize its
    advantages and exploit its features in order to
    write efficient, easy-to-maintained, secured and
    portable programs to satisfy all the requirements.

27
References
  • Schiffman, H., 1997, Thoughts on Java
    http//reality.sgi.com/shiffman/Java-QA.html.
  • http//www-128.ibm.com/developerworks/db2/library/
    techarticle/dm-0506melnyk/
  • http//ei.cs.vt.edu/book/chap1/java_hist.html
  • http//www.engin.umd.umich.edu/CIS/course.des/cis4
    00/java/java.html
  • http//sepwww.stanford.edu/oldsep/matt/join/java/F
    ig/paper_html/node8.html
  • http//www.adahome.com
  • http // en.wikipedia.org
  • Harold, Elliotte R. "comp.lang.java FAQ."
  • Harvey M. Deitel and Paul J. Deitel, Java How to
    Program, 6th Edition, DeitelDeitel, Prentice
    Hall
  • Terrence W. Pratt and Marvin V. Zelkowitz,
    Programming Languages Design and Implementation,
    Fourth Edition, Prentice Hall, 2001

28
I only developed a simple chat application which
is 110 lines of codes. This program basically can
support multiple clients from different machines
but clients must change the servers IP address
according to IP address of the machine that
launches the server file. Once the server file is
executed, it will start listening for clients
connection on port 8000. This program deploys the
concept of Transmission Control Protocol (TCP).
Actually I have already enhanced this program for
other subjects (WRGA6318 and WRGA6315) projects
purpose. Unfortunately, even it is more
efficient, portable and user-friendly the
enhanced version is more than 400 lines of codes
which is not match with the requirement. (Only
simple program with 100-200 LOC)
29
TCPChatServer.java
  • import java.net.
  • import java.io.
  • import java.awt.
  • import java.awt.event.
  • import javax.swing.
  • import java.util.
  • public class TCPchatServer extends JFrame
    implements ActionListener
  • private JTextField jtf new JTextField()
  • private JTextArea jta new JTextArea()
  • private ServerSocket serversocket
  • private Socket socket
  • private DataInputStream in
  • private DataOutputStream out
  • public static void main(String args)
  • new TCPchatServer()
  • public TCPchatServer()
  • JPanel p new JPanel()
  • p.setLayout(new BorderLayout())
  • p.add(new JLabel("Message"),
    BorderLayout.WEST)

30
  • try
  • jta.append("Server started at "new
    Date()"\n")
  • serversocketnew ServerSocket(8000)
  • jta.append("Waiting for connection""\n")
  • socketserversocket.accept()
  • jta.append("Connection successfull""\n")
  • while(true)
  • innew DataInputStream(socket.getInputStream())
  • outnew DataOutputStream(socket.getOutputStream
    ())
  • String messagein.readUTF()
  • jta.append("\nClient "message)
  • catch(IOException e)
  • jta.append("")
  • System.err.println(e)
  • public void actionPerformed(ActionEvent
    e)
  • if(e.getSource()jtf)
  • try
  • String messagee.getActionCommand()
  • jta.append("\nServer "message)

31
TCPChatClient.java
  • import java.net.
  • import java.io.
  • import java.awt.
  • import java.awt.event.
  • import javax.swing.
  • import java.util.
  • public class TCPchatClient extends JFrame
    implements ActionListener
  • private JTextField jtf new JTextField()
  • private JTextArea jta new JTextArea()
  • private Socket socket
  • private DataInputStream input
  • private DataOutputStream output
  • public static void main(String args)
  • new TCPchatClient()
  • public TCPchatClient()
  • JPanel p new JPanel()
  • p.setLayout(new BorderLayout())
  • p.add(new JLabel("Message"),
    BorderLayout.WEST)
  • p.add(jtf, BorderLayout.CENTER)

32
  • setTitle("Client")
  • setVisible(true)
  • setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
  • try
  • jta.append("Client started at "new
    Date()"\n")
  • socketnew Socket("localhost",8000)
  • while(true)
  • inputnew DataInputStream(socket.getInputStream(
    ))
  • outputnew DataOutputStream(socket.getOutputStre
    am())
  • String messageinput.readUTF()
  • jta.append("\nServer "message)
  • catch(IOException e)
  • jta.append("")
  • System.err.println(e)
  • public void actionPerformed(ActionEvent e)
  • if(e.getSource()jtf)
  • try
  • String messagee.getActionCommand()
  • jta.append("\nClient "message)
Write a Comment
User Comments (0)
About PowerShow.com