Download presentation
Presentation is loading. Please wait.
Published bySybil Horn Modified over 8 years ago
1
J2ME Programming
2
Java2 Micro edition Introduction2 2001 년 5 월 26 일 CLDC, MIDP 라이브러리 Reference : http://java.sun.com/products/cldchttp://java.sun.com/products/cldc Reference : http://java.sun.com/products/midphttp://java.sun.com/products/midp 두 Reference 싸이트에서 CLDC 와 MIDP 에 대 한 정보를 얻을 수 있고, 실행파일을 다운 로드 CLDC 는 바이너리 파일, APIs, KVM Source 파 일, API 소스 파일 MIDP 는 바이너리 파일과 APIs
3
Java2 Micro edition Introduction3 2001 년 5 월 26 일 CLDC, MIDP 라이브러리 KVM Source 파일을 이용하여 자신만의 실 행환경을 다시 생성가능 Visual C++ 의 C1 컴파일을 사용하여 컴파 일 컴파일할 때 API 들도 같이 컴파일 zip.exe 파일이 필요
4
Java2 Micro edition Introduction4 2001 년 5 월 26 일 CLDC Directory Java API Native
5
Java2 Micro edition Introduction5 2001 년 5 월 26 일 MIDP Directory
6
Java2 Micro edition Introduction6 2001 년 5 월 26 일 api Contains the Java library class source code that is provided with the release. bin Contains all the binary executables and compiled Java library classes. build Contains makefiles for building the KVM. doc Contains documentation. jam Contains the source code of the optional Java Application Manager (JAM) component that is provided with the KVM. Distribution directories
7
Java2 Micro edition Introduction7 2001 년 5 월 26 일 Directory kvm/VmCommon StartJVM.c Virtual machine startup and command line argument reading. cache.c Inline caching operations for speeding up method lookup. class.c Runtime data structures and operations for representing Java classes. events.c Implementation of a stream-based protocol for event handling. fields.c Runtime data structures and operations for representing fields of objects. frame.c Stack frame and exception handling operations. ETC…
8
Java2 Micro edition Introduction8 2001 년 5 월 26 일 Java code: static native void drawRectangle(int x, int y, int width, int height); Native implementation: C code static void Java_com_sun_kjava_Graphics_drawRectangle() { int height = popStack(); int width = popStack(); int y = popStack(); int x = popStack(); windowSystemDrawRectangle(x, y, width, height); } Example Accessing arguments from native methods
9
Java2 Micro edition Introduction9 2001 년 5 월 26 일 const NativeImplementationType [com_sun_midp_lcdui_DefaultDeviceCaps_natives] = { { "drawLine", Java_com_sun_midp_lcdui_DefaultDeviceCaps_drawLine}, { "drawRect", Java_com_sun_midp_lcdui_DefaultDeviceCaps_drawRect}, { "drawArc", Java_com_sun_midp_lcdui_DefaultDeviceCaps_drawArc}, { "drawChar", Java_com_sun_midp_lcdui_DefaultDeviceCaps_drawChar}, { "drawChars", Java_com_sun_midp_lcdui_DefaultDeviceCaps_drawChars}, { "drawString", Java_com_sun_midp_lcdui_DefaultDeviceCaps_drawString}, { "drawImage", Java_com_sun_midp_lcdui_DefaultDeviceCaps_drawImage}, } Example Accessing arguments from native methods
10
Java2 Micro edition Introduction10 2001 년 5 월 26 일 Kauai VM Architecture Class loader Sub system Runtime data areas Class files Native method interface Native method libraries, Code Execution engine >javac HelloWorld.java HelloWorld.class JNI
11
Java2 Micro edition Introduction11 2001 년 5 월 26 일 Where is target?
12
Java2 Micro edition Introduction12 2001 년 5 월 26 일 J2ME for Wireless Carriers Software Architecture
13
Java2 Micro edition Introduction13 2001 년 5 월 26 일 MIDlet 개발단계 Step 1: 코딩 Step 2: 컴파일 및 사전 검증 Step 3: Manifest 파일 작성 Step 4: 패키징 및 jad 생성 Step 5: 테스트
14
Java2 Micro edition Introduction14 2001 년 5 월 26 일 Hello World import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class HelloWorld extends MIDlet { private Display display; private TextBox mainScreen=null; public HelloWorld() { display=Display.getDisplay(this); mainScreen=new TextBox("TEXT BOX","Hello World",512,0); }
15
Java2 Micro edition Introduction15 2001 년 5 월 26 일 Hello World public void startApp() { display.setCurrent(mainScreen); } public void pauseApp() { } public void destroyApp(boolean unconditional) { }
16
Java2 Micro edition Introduction16 2001 년 5 월 26 일 ScreenText import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class ScreenText extends MIDlet{ private Display display; private Form s1; private Form s2; public ScreenText(){ s1=new Form("Screen1"); s2=new Form("Screen2"); Ticker t=new Ticker("This is a test for switching screen."+"Screen 1 and 2 are switched every 5 seconds."); s1.setTicker(t); s2.setTicker(t); }
17
Java2 Micro edition Introduction17 2001 년 5 월 26 일 ScreenText public void startApp() throws MIDletStateChangeException{ display=Display.getDisplay(this); display.setCurrent(s1); new Thread(new ScreenTestRun()).start(); } public void pauseApp() {} public void destroyApp(boolean unconditional){ display=null; s1=null; s2=null; }
18
Java2 Micro edition Introduction18 2001 년 5 월 26 일 ScreenText class ScreenTestRun implements Runnable{ public void run(){ while(true){ try{ Thread.sleep(5000); if(display.getCurrent()==s1){ display.setCurrent(s2); } else{ display.setCurrent(s1); } catch(Exception e){} }
19
Java2 Micro edition Introduction19 2001 년 5 월 26 일 J2ME Wireless Toolkit J2ME MIDlet 의 개발을 지원하는 프로그램 과 API set http://www.sun.com/software/communityso urce/j2me/download.html 에서 다운로드 가 능 http://www.sun.com/software/communityso urce/j2me/download.html 설치된 디렉토리를 환경변수 J2ME 로 설정 해 준다.
20
Java2 Micro edition Introduction20 2001 년 5 월 26 일 컴파일 JDK 의 common Java Compiler 사용 javac -g:none -bootclasspath %J2ME%\lib\midpapi.zip -d. -classpath. 자바파일이름
21
Java2 Micro edition Introduction21 2001 년 5 월 26 일 사전검증 생성된 class 파일이 규격에 맞는가 검증 Class 파일을 약간 축소시킴 preverify -classpath %J2ME%\lib\midpapi.zip;. -d..
22
Java2 Micro edition Introduction22 2001 년 5 월 26 일 Manifest 파일 패키징시 필요한 정보를 저장 MIDlet-1: HelloWorld, /Icon.png, HelloWorld MIDlet-Name: KJava MIDlet-Vendor: Kim Insu MIDlet-Version: 1.0 MicroEdition-Configuration: CLDC-1.0 MicroEdition-Profile: MIDP-1.0
23
Java2 Micro edition Introduction23 2001 년 5 월 26 일 패키징 Java 의 JAR (Java archive) 사용 Manifest 의 정보를 포함하여 각 class, resource 등을 압축 jar cmvf MANIFEST.MF 패키지이름 대상 파일
24
Java2 Micro edition Introduction24 2001 년 5 월 26 일 패키징
25
Java2 Micro edition Introduction25 2001 년 5 월 26 일 JAD (descriptor) 생성 JAR 파일의 내용을 설명 Manifest 파일과 유사한 형태를 가짐
26
Java2 Micro edition Introduction26 2001 년 5 월 26 일 JAD MIDlet-1: HelloWorld, /Icon.png, HelloWorld MIDlet-Jar-Size: 2890 MIDlet-Jar-URL: http://ngic.konkuk.ac.kr/~darkguy/KJava.jar http://ngic.konkuk.ac.kr/~darkguy/KJava.jar MIDlet-Name: Kjava MIDlet-Vendor: Kim Insu MIDlet-Version: 1.0 MicroEdition-Configuration: CLDC-1.0 MicroEdition-Profile: MIDP-1.0
27
Java2 Micro edition Introduction27 2001 년 5 월 26 일 테스트 midp 에뮬레이터를 사용한 로컬테스트 midp -classpath JAR 파일명 –descriptor JAD 파일명
28
Java2 Micro edition Introduction28 2001 년 5 월 26 일 테스트 – MIDP (local)
29
Java2 Micro edition Introduction29 2001 년 5 월 26 일 KToolBar MIDlet 의 컴파일, 사전검증, 패키징, 실행등 의 번거로운 작업을 관리 J2ME Wireless Toolkit 에 포함
30
Java2 Micro edition Introduction30 2001 년 5 월 26 일 KToolBar
31
Java2 Micro edition Introduction31 2001 년 5 월 26 일 KToolBar 새로운 프로젝트 생성
32
Java2 Micro edition Introduction32 2001 년 5 월 26 일 KToolBar MIDlet 수트의 필수 어트리뷰트 설정 Manifest, JAD 파일에 사용
33
Java2 Micro edition Introduction33 2001 년 5 월 26 일 KToolBar 선택적 어트리뷰트 설정
34
Java2 Micro edition Introduction34 2001 년 5 월 26 일 KToolBar 수트에 포함될 MIDlet 설정
35
Java2 Micro edition Introduction35 2001 년 5 월 26 일 KToolBar 프로젝트의 ‘src’ 디렉토리에 소스코드 작성
36
Java2 Micro edition Introduction36 2001 년 5 월 26 일 KToolBar ‘build’ 버튼으로 컴파일, 사전검사, 패키징
37
Java2 Micro edition Introduction37 2001 년 5 월 26 일 KToolBar 생성된 JAD, JAR, Manifest 파일
38
Java2 Micro edition Introduction38 2001 년 5 월 26 일 KToolBar ‘run’ 버튼으로 MIDlet 의 실행
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.