computação móvel j2me. java 2 platform (1) java 2 standard edition (j2se) – desktop...

22
Computação Móvel J2ME

Upload: brenda-rebeca-ferrao-nunes

Post on 07-Apr-2016

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

Computação Móvel

J2ME

Page 2: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

Java 2 Platform (1)

• Java 2 Standard Edition (J2SE)– Desktop applications

• Java 2 Enterprise Edition (J2EE)– Server applications

• Java 2 Micro Edition (J2ME) – Handheld/embedded devices

• Each one is a subset of the previousComputação Móvel 2008/2009

Page 3: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

Java 2 Platform (2)

Computação Móvel 2008/2009

source: http://java.sun.com

Page 4: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

Java 2 Micro Edition (J2ME)

• Presented in 1999 (Java is from 1995)• Supported by more than 600 devices currently

in the market• Open source

Computação Móvel 2008/2009

Page 5: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

Java 2 Micro Edition

• The Java runtime environment is adapted for constrained devices:– extremely limited memory;– small screen sizes;– alternative input methods;– slow processors.

Computação Móvel 2008/2009

Page 6: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

J2ME Core Concepts

• Configurations– The Java runtime environment

• Profiles– Fills the missing functionality

• Optional packages– Support for additional features

Computação Móvel 2008/2009

Page 7: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

J2ME Configurations

• A Java virtual machine (VM) to execute Java bytecode.

• Native code to interface to the underlying system.

• A set of core Java runtime classes.

Computação Móvel 2008/2009

Page 8: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

J2ME Configurations

• Connected Limited Device Configuration(CLDC)– very constrained (limited) devices– just a basic subset from the java.lang, java.io

and java.util packages, with a few additional classes from javax.microedition.io

• Connected Device Configuration (CDC)– full Java VM– larger set of core classes– Superset of CLDC

Computação Móvel 2008/2009

Page 9: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

J2ME Profiles

• Adds domain-specific classes to a configuration

• Supports specific uses of a device

Computação Móvel 2008/2009

Page 10: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

J2ME Profiles• Mobile Information Device Profile (MIDP)

– CLDC-based profile for running applications on cellphones and interactive pagers with small screens, wireless HTTP connectivity, and limited memory.

• Personal Digital Assistant Profile (PDAP) (still in development)– extends MIDP with additional classes and features for more powerful

handheld devices.• Foundation Profile (FP)

– extends the CDC with additional J2SE classes• Personal Basis Profile (PBP)

– extends the FP with lightweight (AWT-derived) user interface classes and a new application model

• Personal Profile– extends the PBP with applet support and heavyweight UI classes

Computação Móvel 2008/2009

Page 11: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

J2ME Optional Packages

• support for additional behaviors that don't really belong in one specific configuration or profile (E.g. Bluetooth)

• Some optional packages– The RMI Optional Package– the Java APIs for Bluetooth– the JDBC Optional Package for CDC/Foundation

Profile

Computação Móvel 2008/2009

Page 12: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

Connected Limited Device Configuration (CLDC)

• Capabilities of the Java virtual machine (VM), which is not a full-featured Java VM.

• Very small subset of the J2SE 1.3 classes.• New set of APIs (application programming

interfaces) for input/output called the Generic Connection Framework.

• CLDC does not define– APIs related to user interfaces– How applications are loaded onto a device or how

they are activated or deactivated.

Computação Móvel 2008/2009

Page 13: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

MIDP Devices

• Enough memory to run MIDP applications• A bit addressable display at least 96 pixels

wide by 56 pixels high, either monochrome or color

• A keypad, keyboard, or touch screen• Two-way wireless networking capability

Computação Móvel 2008/2009

Page 14: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

MIDP APIs

• Support for application lifecycle management similar to the way applets are defined in Java 2 Standard Edition

• Persistent storage of data.• HTTP-based network connectivity based on

the CLDC's Generic Connection Framework• Simple user interface support, with enough

flexibility to build games or business applications

Computação Móvel 2008/2009

Page 15: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

MIDlet and MIDlet Suites

• MIDlet– MIDP application– Class that extends

javax.microedition.midlet.MIDlet • MIDlet suite– Packages one or more MIDlets– Consists of two files• Jar file• Jad file (application descriptor file)

Computação Móvel 2008/2009

Page 16: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

CLDC Wireless Platform

Computação Móvel 2008/2009

source: http://java.sun.com

Page 17: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

Laboratórios – Trabalho para hoje

• Criação e instalação de uma aplicação J2ME– HelloWorld

• Comunicação entre dois dispositivos– NetworkDemo (comunicação com sockets)

• Alteração de NetworkDemo– Cliente local vs cliente remoto– interface gráfica

Computação Móvel 2008/2009

Page 18: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

Aplicações disponíveis no laboratório

• Eclipse (com o j2me instalado)• Sun Java Wireless Toolkit for CLDC

• Os ficheiros de exemplo estão na página da cadeira

Computação Móvel 2008/2009

Page 19: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

HelloWorld (1)• Abrir Eclipse• Criar novo projecto (escolhendo other…)• Escolher J2ME Midlet Suite• Preencher o nome do projecto• Escolher o device onde vai correr (em principio terá apenas

uma opção de escolha)• Copiar ficheiros do HelloWorld para a directoria src no

projecto• Alterar definições do ficheiro .JAD para incluir a MIDlet que

vai correr• Criar o pacote

– No projecto escolher J2ME->create package

Computação Móvel 2008/2009

Page 20: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

HelloWorld (2)

• Correr directamente através do eclipse– Clicar na MIDlet e escolher Run

• Correr através do emulador– Correr o emulador– Carregar o ficheiro .JAD gerado anteriormente

Computação Móvel 2008/2009

Page 21: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

NetworkDemo

• Criar a aplicação (.JAD) da forma descrita anteriormente

• Lançar dois emuladores na mesma máquina• Instalar a aplicação em cada um deles• Escolher um como servidor e outro como

cliente• Ver a comunicação a funcionar

Computação Móvel 2008/2009

Page 22: Computação Móvel J2ME. Java 2 Platform (1) Java 2 Standard Edition (J2SE) – Desktop applications Java 2 Enterprise Edition (J2EE) – Server applications

NetWorkDemo2

• Alterar a aplicação anterior• O servidor corre numa máquina e o cliente

noutra• O cliente quando corre solicita ao utilizador,

através de uma caixa de texto, qual o endereço do servidor

• Após a ligação estar estabelecida o enviar da mensagem é efectuada carregando num botão que será criada para tal na interface do emulador

Computação Móvel 2008/2009