![Page 1: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/1.jpg)
1
Java vs. .Net
Livslang UddannelseAugust 20th, 2004
Bent ThomsenPhD, DIC, Cand.Scient, EurIng, CEng, FBCS, MACM, MIEEE
[email protected] of Computer Science
Aalborg University
![Page 2: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/2.jpg)
2
Services on Demand Vision
Valuecreation
Resources • Physical• Scarce
• Supply-driven
• Massproduction
Industrial age corp.
Vertical Integrated
MainframeDumb
Virtual Corporation
Hub & spoke Tightly coupled
PCClient-server
EDI
• Customer–driven
• Serviceenhanced customization
• Digital knowledge• Abundance
Business Web
Modular Loosely coupled
Internet-enabled
Mobile dev.
Wireless and pervasive
Wireless and pervasive
![Page 3: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/3.jpg)
3
Company ACompany A
Consumers, PartnersConsumers, Partners
MobileMobileEmployeesEmployees
Company BCompany B
Customers Customers Partners Partners SuppliersSuppliers
Consumers, PartnersConsumers, Partners
MobileMobileEmployeesEmployees
The Services on Demand Vision The Virtual Enterprise
Slide from Microsoft .Net presentation
![Page 4: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/4.jpg)
4
Services on Demand Vision
Revolutionary new business methods
Unlimited choice
Individual is King
+ interactivity
Cheap, Faster, Global Networking via
Internet
Cheap, Faster Processing
Converged Networks / Broadcast
Interactive Digital Content
Array of Access Devices
=
But how to build this vision?
![Page 5: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/5.jpg)
5
The Answer is: Web Services
• A Web service is like a Web site without a user interface, that serves programs instead of people.
• Instead of getting requests from browsers and returning web pages in response, a web service:– receives a request formatted in XML from an application, – performs a task, – and returns an XML-formatted response.
• Web Services are delivered using open industry standards– Services to be described in WSDL– Services to located via UDDI– Data to be exchanged via XML– Protocols are HTTP and SOAP
• BUT Back-end systems still need to be developed! • And the smart clients still ned to be developed!
![Page 6: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/6.jpg)
6
The basic problem ...• If you have software components ...
• ... and they shall work together in the same transaction• ... and they shall have the same security boundaries• ... and they shall share the same session state• ... and they shall be remotely accessible• ... and they shall not suffer from code overload
• Then you must have ...• ... an infrastructure that hosts such components for
secure remote and local access• ... an infrastructure that manages transactions• ... an infrastructure that hides infrastructure code
• The answer is: • Applications on Application Servers• Implemented in an Enterprise Solution Framework
![Page 7: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/7.jpg)
7
Sun One Architecture
Support major standards initiatives such as XML, SOAP,
UDDI, WDSL and … to make it ready for developers who
want to take advantage of the Services on Demand vision
![Page 8: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/8.jpg)
8
Microsoft’s .NET
Support major standards initiatives such as XML, SOAP,
UDDI, WDSL and … to make it ready for developers who
want to take advantage of the Services on Demand vision
![Page 9: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/9.jpg)
9
A typical .NET Enterprise Solution
SQLServer
IIS on W2k Server
.NET managed
componentASP.NET
WindowsClient
Browser
![Page 10: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/10.jpg)
10
A typical J2EE Enterprise Solution
DB Server
Java App Server
EJBServlet
JSP
Java Client
Browser
![Page 11: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/11.jpg)
11
The rest of this talk
• What is Java?– J2SE
– J2EE
– J2ME
• What is .Net?– CLR
– CTS
– VS.Net
– C#
• Java vs. .Net how do they compare?• The future
![Page 12: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/12.jpg)
12
What is Java?
• A programming language– Fully buzzword-compliant:
A simple, object oriented, distributed, interpreted, robust, secure, architecture neutral, portable, high performance, multithreaded, dynamic language.
From: Java: An OverviewJames Gosling, Sun Microsystems, February 1995.
![Page 13: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/13.jpg)
13
What Else is Java?
• According to Gosling:– “An environment”
– “A platform”
– “A way of thinking”
– …ok, whatever
• Java is a phenomenon– Took the world by storm in 1995 when introduced with
the HotJava web Browser
– Quickly integrated with Netscape browser
![Page 14: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/14.jpg)
14
Some History
• 1993 Oak project at Sun– small, robust, architecture independent, Object-Oriented, language to control
interactive TV.– didn’t go anywhere
• 1995 Oak becomes Java– Focus on the web
• 1996 Java 1.0 available• 1997 (March) Java 1.1 - some language changes, much larger library, new
event handling model • 1997 (September) Java 1.2 beta – huge increase in libraries including Swing,
new collection classes, J2EE• 1998 (October) Java 1.2 final (Java2!)• 2000 (April) Java 1.3 final• 2001 Java 1.4 final (assert)• 2004 Java 1.5 (parameterized types, enum, …)• 2005 J2EE 1.5
![Page 15: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/15.jpg)
15
Java Design Goals
• Support secure, high-performance, robust applications running as-is on multiple platforms and over networks
• “Architecture-neutral”, portable, allow dynamic updates and adapt to new environments
• Look enough like C++ for programmer comfort• Support object-oriented programming• Support concurrency (multithreading)• Simplicity • In some ways, Java is not new
– Strongly influenced by the Simula language developed in Norway 35 years ago
– Syntax from C, bytecode from SmallTalk
![Page 16: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/16.jpg)
16
Basic Java Components
3 parts; known as “The Platform”
1. The Language– Syntax– Compiler
2. The API’s– Standard set of prewritten packages
3. The Virtual Machine (VM)– An intermediate layer between Java and the
underlying OS– Now comes in many different flavours
![Page 17: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/17.jpg)
17
Java Advantages
• Simplicity– Unlike C++, which inherits much C hocus-pocus, Java
was designed to be developer-friendly from the start.
• Built-In Features– Memory management: no “memory leaks”
– Automatic array-bound checking
– “Soft landings”. Errors are handled gracefully, with stack-rollback traces (even line-numbered!). No more core dumps.
![Page 18: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/18.jpg)
18
Hello World in Java
public class HelloWorld {
public static void main (String [ ] args) {
System.out.println(“Hello World”);
}
}
![Page 19: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/19.jpg)
19
It’s all about objects
• Java is a purely object-oriented language• (well, almost)
• Fundamental unit of a program is a class• Instances of classes are objects
– May be helpful to think of objects receiving messages and replying to them instead of calling methods and returning values
![Page 20: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/20.jpg)
20
object-oriented
• encapsulation• overriding• reuse• dynamic dispatch
(virtual call)
class Point { int x,y; draw(Graphics g) { g.putPixel(x,y);}}
class Point { int x,y; draw(Graphics g) { g.putPixel(x,y);}}
class ColorPoint extends Point {
Color c; draw(Graphics g) { g.setColor(c); super.draw(g);}}
class ColorPoint extends Point {
Color c; draw(Graphics g) { g.setColor(c); super.draw(g);}}
Point p;p.draw(g);Point p;p.draw(g);
![Page 21: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/21.jpg)
21
Other Bonuses
• Built-in GUI package: the AWT• Single Standard for API documentation
– JavaDoc: Generates professional-looking API for any homegrown classes
• Jar: “Tar”-like compression and bundling, works on any platform
• Runtime Representation– Can determine the class of any object at runtime
![Page 22: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/22.jpg)
22
Java Advantages
• Guaranteed Behavior– “Write once, run anywhere”
• By nature of the VM– Platform-independent standards
• An int is a 32-bit 2’s-comp. signed integer• A double is a 64-bit IEEE-754 F.P. quantity
• It’s Free!– The entire Java development environment (the “JDK”)
is free for download from Sun• Windows, Solaris, Linux, Mac OS versions
– Huge base of freely-available Java code
![Page 23: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/23.jpg)
23
Some Standard Library Packages
• java.lang – core classes (Math, String, System, Integer, Character, etc.)– Imported automatically
• java.util – collections, date/time, random numbers• java.io – input/output streams, files• java.net – network I/O, sockets, URLs• java.awt – basic (original) graphical user interface• java.awt.event – GUI event handling• javax.swing – sophisticated newer GUI built on top of
AWT
![Page 24: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/24.jpg)
24
Java Add-Ons
• Java Beans– Component-based Java
• JDBC– A Java interface to relational DBs via SQL
• JNI (Java Native Interface)– Java interface to non-Java native apps
• Applets– Small client-side Java applications running in a web browser
• Servlets– Server-based programs for request processing
• Midlets– Small Java applications for mobile phones
![Page 25: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/25.jpg)
25
Java Applets
• Applets:
– Small embeddable application
– A Java applet is a compiled Java program, consisting of classes just like any other Java program
– Applets are autonomous programs confined within the walls of the browser or applet viewer. Can interact with user and communicate with the host over the network
![Page 26: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/26.jpg)
26
Sample Applet
//create a file called HelloWeb.javapublic class HelloWeb extends java.applet.Applet{ public void paint( java.awt.Graphics gc) { gc.drawString (“Hello World, Welcome to Java”, 125, 95); }}
• Compile the java source file (using JDK): javac HelloWeb.java
• Create an html file that embeds the applet using the <applet> tag
• Load the html page into a java supported browser
![Page 27: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/27.jpg)
27
Sample HTML Document
<html><head></head><body>
<applet code=HelloWeb width=300 height=200 </applet></body></html>
• Save it as HelloWeb.html
• Open HelloWeb.html using the browser
![Page 28: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/28.jpg)
28
ByteCode: Food for the VM
• For most languages, compilation produces machine code
• Java compilation produces “bytecode”– Intermediate code readable by the VM– Transferable across the Internet as applets
• VM interprets BC into instructions– Partly responsible for performance lag
• ByteCode produced on any platform may be executed on any other platform which supports a VM
![Page 29: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/29.jpg)
29
virtual machine
execution model of Java
source(text) compiler
CPU
bytecodeinterpreterbytecodeinterpreter
dynamicloading
JITcompiler
JITcompiler
compiledcode
compiledcode
JVML
verifier
bytecode(aka. class file)
![Page 30: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/30.jpg)
30
The JIT
• Just-In-Time compiler• Translates bytecode into machine code at runtime
– 1-time overhead when run initiated
– Performance increase 10-30 times
• Now the default for most JVM’s– Can be turned off if desired
– JIT can apply statistical optimizations based on runtime usage profile
![Page 31: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/31.jpg)
31
Not just one JVM, but a whole family
• JVM (J2EE & J2SE)– Well-known Java Virtual Machine.
• CVM, KVM (J2ME)– Small devices.– Reduces some VM features to fit resource-constrained
devices.
• JCVM (Java Card)– Smart cards.– It has least VM features.
• And there are also lots of other JVMs
![Page 32: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/32.jpg)
32
Java vs. C
![Page 33: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/33.jpg)
33
Java 1.5 Standard Edition
• new Java Language Features– Autoboxing/unboxing– Static Import– Meta data– Variable Arguments (“Varargs”)– Enhanced for loop– Generics– Typesafe enums
• Minimal changes to JVM– Default compilation does not require new JVM– If you use new Java 1.5 features:
• Will not run on older JVMs• Must tell javac compiler to run with prior version of compiler:
– -source or –target keywords
• New Java keywords kept to a minimum
![Page 34: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/34.jpg)
34
Autoboxing
• Up through Java 1.4, primitive types cannot be used where an object is required– They had to be wrapped, or boxed, for instance:
myStack.push(new Integer(25));
• Primitive types still cannot be used where an object is required…
• …But Java 1.5 now does this conversion automatically:– Now you can say myStack.push(25);
• What happens at runtime is still the same– It’s just that the compiler does the conversion for you
![Page 35: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/35.jpg)
35
Auto-unboxing
• Just as you could not use primitive types where an Object was required, you could not use an Object where a primitive type was required– You had to do your own unwrapping, or un-boxing
– For instance, you had to write code such as:int result = ((Integer)myStack.pop()).intValue();
– Now you can just write:int result = myStack.pop();
– Even more striking,myStack.push(new Integer(((Integer)myStack.pop()).intValue() + ((Integer)myStack.pop()).intValue()));becomesmyStack.push(myStack.pop() + myStack.pop());
![Page 36: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/36.jpg)
36
printf()method example
• System.out method call to printf():
System.out.printf(“%d %.2f %.2e\n", 78, 1.23456, 1.23456);
• will print:
78 1.23 1.23e+00
![Page 37: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/37.jpg)
37
Generic types
• Up through Java 1.4, collections hold arbitrary Objects• If you wanted, say, a Vector of Employees, you had two basic
choices:– Use a Vector
• Adding an Employee is easy (but so is adding any other Object, however inappropriate)
• Getting an Employee from the Vector usually requires a cast, which may result in a runtime error
– Extend Vector with an EmployeeVector class• Checking is done at compile time (which is better than runtime)• It’s a lot of extra work
• Generic types do the second of these automatically for you– Syntax:
Vector<Employee> employees = new Vector<Employee>();
![Page 38: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/38.jpg)
38
An example
• Instead of:– ArrayList list = new ArrayList();
list.add(0, new Integer(42));int total = ((Integer)list.get(0)).intValue();
• You can say:– ArrayList<Integer> list = new ArrayList<Integer>();
list.add(0, new Integer(42));int total = list.get(0).intValue();
• Advantages:– Less work to create specialized data structures– Checking done at compile time rather than runtime– For C++ programmers, the syntax is familiar
• Disadvantage:– Yet more ugly syntax to learn
![Page 39: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/39.jpg)
39
Java Platform & VM & Devices
![Page 40: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/40.jpg)
40
J2EE – Enterprise Java
• J2EE: Java 2 Enterprise Edition– Superset of Java 2 Standard Edition (J2SE)
– Adds enterprise features to Java Libraries
• Defined through the Java Community Process (JCP)– plus whatever Sun sees fit, Sun has last word
– Sun writes almost all specs and other contribute
– Submitters essentially surrender all rights to Sun
• Wholly owned property of Sun Microsystems– Licensing controlled by Sun, by Sun's rules
– JCP Broadens Sun's architect's base
![Page 41: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/41.jpg)
41
Enterprise Java
• J2EE (1.4+) is an infrastructure specification for:– Components ("Beans")– Data Source Connectivity– XML and Messaging– Web Pages and Web Services
• Implemented by: Sun, IBM, BEA, Oracle, etc.– IBM WebSphere (37% market share 2002/33% 2000)– BEA WebLogic (29% MS 2002/59% 2000)– SUN iPlanet (4% MS 2002/3% 2000)– Oracle Application Server 9i– Fujitsu Interstage– …
• All vendors implement core specification, but:– Some areas in J2EE are (intentionally) not specified– The more specific a functionality the more proprietary the implementation gets
Numbers from the web, allegedly originally from Gartner DataQuest
![Page 42: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/42.jpg)
42
J2EE 1.5
• J2EE (1.5) preview of 26.4.2004– Focus on ease of development
• Generics and metadata as in J2SE 1.5
• Java Studio Creator tool (in beta from April 2004)
– Timeframe
• To be discussed at JavaOne in June
• Finalized in approximately one year
![Page 43: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/43.jpg)
43
Java 2 Platform Architecture
![Page 44: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/44.jpg)
44
Java 2 Micro Edition
“Java 2 Platform, Micro Edition (J2ME) is a Java based
Programming language that lets you build client side
Applications (called MIDlets) optimized for mobile
devices that have limited resources.”
![Page 45: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/45.jpg)
45
J2ME Executive Committee
• BEA Systems
• Cisco Systems
• Ericsson
• IBM
• Insignia
• Matsushita (Panasonic)
• Motorola
• Nokia
• Palm
• Philips
• Research In Motion
• Siemens
• Sony
• Sun Microsystems
• Texas Instruments
• Zucotto Wireless
![Page 46: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/46.jpg)
46
KVM
Java 2 Micro Edition
CLDC
Java 2 Micro Edition
JVM
CDC
Foundation Profile
Mobile phone
Midlet
MIDP
PortabilityApplications
APIs
Libraries
![Page 47: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/47.jpg)
47
Typical J2ME Technology Stack
Mobile Information
Device Profile
KVMCLDC = KVM + J2ME Core
APIs in this
example DSP chip(e.g., ARM)
J2ME core APIs
YourMIDlet
Yellow Pages, train schedules and ticketing, games…
UI, HTTP networking...
Threads, no Floats…
32-bit RISC, 256K ROM, 256K Flash, 64K RAM
![Page 48: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/48.jpg)
48
MIDP Application Lifecycle• MIDP applications are known as “MIDlets”• MIDlets move from state to state in the
lifecycle, as indicated.– Start – acquire resources and start executing– Pause – release resources and become quiescent (wait)– Destroy – release all resources, destroy threads, and
end all activity• Managed by the JavaTM Application
Manager (JAM)– A software app that comes with MIDP
implementation that controls the installation, execution and removal of MIDLets
– Provides an execution environment for a MIDLet– Handles all errors that occurs during installation
and execution of app without crashing the system
Pause
Active
Destroyed
star
tAp
pd
estr
oyA
pp
pau
seA
pp
des
tro
yAp
p
![Page 49: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/49.jpg)
49
Tour of CLDC/MIDP
• Packages– Javax.microedition.io– Javax.microedition.lcdui– Javax.microedition.midlet– Javax.microedtion.rms
• Contains user interface widgets– Form, TextField, TextBox, DateField, List, Image, Gauge, Alert, Canvas,
Graphics, Display
• Event handling classes – Command and CommandListener• Two APIs, high and low
– High level for GUI widgets, scrolling, etc.– Low level for graphics and fine-grained UI control
![Page 50: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/50.jpg)
50
Sample Code import javax.microedition.lcdui.*;import javax.microedition.midlet.*;
public class HiMIDlet extends MIDlet {
private TextBox textbox; public HiMIDlet() { textbox = new TextBox ("", "Hello World!", 20, 0); }
public void startApp() { Display.getDisplay(this).setCurrent(textbox); } public void pauseApp() {} public void destroyApp(boolean unconditional) {}}
![Page 51: Java vs. .Net Livslang Uddannelse August 20 th , 2004](https://reader036.vdocuments.net/reader036/viewer/2022062518/56814be4550346895db8bcf3/html5/thumbnails/51.jpg)
51
Future of Java
• Java 1.5 SE is very close to C# 2.0/.Net CLR• J2EE 1.5 and Sun Java Studio Creator somewhat close
to VS.Net• Some talk of JVM as multi-language platform, but not
really so far …• Sun in “Java as Open Source” battle with IBM
– IBM push for truly open source Java
– Others hesitate (even Open Source JBoss)