A apresentação está carregando. Por favor, espere

A apresentação está carregando. Por favor, espere

Plataforma Java 2 - Micro Edition (J2ME) Prof. Afonso Ferreira Miguel, MSc.

Apresentações semelhantes


Apresentação em tema: "Plataforma Java 2 - Micro Edition (J2ME) Prof. Afonso Ferreira Miguel, MSc."— Transcrição da apresentação:

1 Plataforma Java 2 - Micro Edition (J2ME) Prof. Afonso Ferreira Miguel, MSc

2 O que é Java Simple Object oriented Architecture Neutral and Portable Distributed High performance Interpreted Multithreaded Robust Dynamic Secure

3 Java - Estrutura Geral Ciclo de desenvolvimento: Plataforma: The Java Virtual Machine (Java VM) The Java Application Programming Interface (Java API)

4 O que é J2ME "a highly optimized Java run-time environment targeting a wide range of consumer products, including pagers, cellular phones, screen-phones, digital set-top boxes and car navigation systems." Sun Microsystems Announced in June 1999 at the JavaOne Developer Conference, J2ME brings the cross-platform functionality of the Java language to smaller devices, allowing mobile wireless devices to share applications. With J2ME, Sun has adapted the Java platform for consumer products that incorporate or are based on small computing devices.

5 J2ME - Estrutura Geral Configuration  basic run-time environment (core classes and a specific JVM); Profile  Application (domain-specific classes ). Configuration Profile Virtual Machines J2ME

6 J2ME - Configuration Configuration Connected Limited Device Configuration (CLDC) Utiliza KVM para dispositivos de 16 ou 32-bit com espaço de memória limitado (<500k); Utilizada para pequenas aplicações J2ME; Exemplo de wireless device : Palm Hand-held. Connected Device Configuration (CDC) Utiliza C virtual machine (CVM) para dispositivos de 32-bits Aquitturas com mais de 2MB Exemplo - Net TV box.

7 Device x CLDC 160 to 512 kilobytes of total memory available for the Java platform; Limited power, often battery powered; Network connectivity, often with a wireless, inconsistent connection and with limited bandwidth; User interfaces with varying degrees of sophistication; sometimes with no interface at all. Exemplos: wireless phones; pagers; mainstream personal digital assistants (PDAs); small retail payment terminals.

8 Device x CDC Powered by a 32-bit processor; Two megabytes or more of total memory available for the Java platform; Network connectivity, often with a wireless, inconsistent connection and with limited bandwidth; User interfaces with varying degrees of sophistication; sometimes with no interface. residential gateways; PDAs; Organizers; home appliances; point-of-sale terminals; car navigation systems. Exemplos:

9 CDC x CLDC Conclusão: progs J2SE e J2ME na maioria das vezes não são compatíveis (interface) "Write Once, Run Anywhere.“ ????

10 J2ME - Profile Profile Define o tipo de device suportado pela aplicação; Construído sobre Configuration (CDC/CLDC); Sobre CLDC, disponível em dois modelos: KJava; MIDP - Mobile Information Device Profile (classes para telefones celulares e PDAs). Sobre CDC, disponível o Foundation Profile que permite criar profiles personalisados;

11 Profile 1: KJava Profile KJava é propriedade da Sun; Roda sobre uma JVM (Java Virtual Machine) chamada KVM (KJava Virtual Machine); Versões preliminares para telefones celulares e PDAs; Construído sobre CLDC.

12 Profile 2: MIDP Mobile Information Device Profile Profile MIDP é um padrão aberto (não proprietário); Roda também sobre a JVM (Java Virtual Machine) chamada KVM; Versões finais disponíveis para telefones celulares e PDAs; Construído sobre CLDC.

13 Kava x MIDP Profile KJava foi o primeiro profile da Sun; Foi adotado como padrão por vários desenvolvedores; MIDP foi aprovado por um Java Community Process, garantindo a independência de fabricante; Novos produtos geralmente são desenvolvidos para MIDP, brevemente desaparecendo o KJava; 2001 Sun anuncia o lançamento do MIDP para PALM.

14 J2ME x J2SE x J2EE

15 Considerações para projeto em pequenos dispositivos Keep it simple: Remove unnecessary features; Smaller is better: Smaller applications use less memory and require shorter installation times; Minimize run-time memory use: Use scalar types in place of object types; Do not depend on the garbage collector; Use lazy instantiation, only allocating objects on an as-needed basis; Release resources quickly, reuse objects, and avoid exceptions.

16 Considerações para projeto em dispositivos móveis Let the server do most of the work: move the computationally intensive tasks to the server, and let the server run them for you. Let the mobile device handle the interface and minimal amounts of computations, and let the server do the intensive work. Choose the language carefully: J2ME still is in its infancy and may not be the best option. Other object-oriented languages, like C++, could be a better choice, depending on your needs.

17 Considerações sobre desempenho Use local variables: it is quicker to access local variables than to access class members. Avoid string concatenation: string concatenation decreases performance and can increase the application's peak memory usage. Use threads and avoid synchronization: any operation that takes more than 1/10 of a second to run requires a separate thread. Avoiding synchronization can increase performance as well. Separate the model using the model-view-controller (MVC): MVC separates the logic from the code that controls the presentation.

18 Configurando o sistema... Recursos necessários: 1.Java 2 SDK (j2sdk-1_4_0_01-windows-i586.exe); 2.Java 2 ME – Wireless Toolkit (j2me_wireless_toolkit- 1_0_4_01-bin-win.exe); 3.JCreator (jcrea250.zip); 4.Palm-OS Emulator (emulator-win.zip); 5.PALM-ROM Mirror (Palm Afonso.rom)

19 Configurando o sistema... Procedimentos: 1.Instalar Java 2 SDK, Java 2 ME – Wireless Toolkit e Jcreator (nesta ordem) utilizando as definições padrão; 2.Instalar Palm-OS Emulator descompactando para um diretório padrão (PALM-EMUL); 3.Copiar Palm Afonso.rom para o mesmo diretório do item 2.

20 Desenvolvendo aplicativos... Considerações iniciais sobre inteface gráfica em MIDP: MIDP possui tanto métodos de baixo-nível como de alto-nível. Métodos de baixo-nível permitem acessar a inteface do dispositivo tratando pixel a pixel. Métodos de alto-nível, inserem controles próprios da API aparecendo conforme a implementação MIDP para o dispositivo.

21 Desenvolvendo aplicativos... MIDLET

22 J2ME Wireless Toolkit

23 1ª aplicação...... Hello World Criar projeto com botão New Project... Pressionar OK Passo 1: Criando projeto no J2ME Wireless Toolkit

24 1ª aplicação...... Hello World Criar um Empty Project no diretório c:\Wtk104\apps\ com o mesmo nome do projeto criado no J2ME Wireless Toolkit (MeuTeste); Criar um Java File chamado HelloWorld.java no diretório c:\Wtk104\apps\MeuTeste\src\ Passo 2: Criando projeto no JCreator

25 1ª aplicação...... Hello World Entrar com o código a seguir: Salvar Passo 3: código Java import javax.microedition.midlet.MIDlet; import javax.microedition.lcdui.*; public class HelloWorld extends MIDlet implements CommandListener { private Form form; public HelloWorld() { form = new Form("Isto é um teste"); form.append("Olá Mundo!"); form.addCommand( new Command( "Sair", Command.EXIT, 1 ) ); form.setCommandListener( this ); } public void startApp() { Display display = Display.getDisplay(this); display.setCurrent( form ); } public void pauseApp() { } public void destroyApp(boolean unconditional) { form = null; } public void commandAction(Command c, Displayable d) { destroyApp(true); notifyDestroyed(); }

26 1ª aplicação...... Hello World Passo 4: compilando e testando... Voltar ao J2ME Wireless Toolkit compilar o projeto com o botão Build; Selecionar o device a ser emulado (Motorola_i85s); Executar através do botão Run; Selecionar a aplicação e executá-la através do botão Launch.


Carregar ppt "Plataforma Java 2 - Micro Edition (J2ME) Prof. Afonso Ferreira Miguel, MSc."

Apresentações semelhantes


Anúncios Google