Conversion of Java Applets Animations to Java Midlets
Total Page:16
File Type:pdf, Size:1020Kb
Conversion of Java Applets Animations to Java MIDlets Kapil Kadam, Sameer Sahasrabudhe Abstract—Java applets are used in e-learning, mainly for It has two important APIs (Application Programming creating animations. Many leading educational and Interface) - The CLDC API (Connected Limited Device professional organizations have large repositories of Configuration) and the MIDP API (Mobile Information animations, created using Java applets which are mostly for Device Profile) [8]. desktops. Use of mobile phones is increasing especially amongst Only a subset of Core Java APIs java.lang, java.io and students, and creating new eLearning content for mobile java.util are supported by J2ME. For example, the java.lang phones is resource intensive. The Java applets available are not in J2ME (CLDC 1.1 version) has 17 classes and 1 interface, compatible with the mobile technology. It is desirable to have a methodology to adapt existing Java animations on mobile compared with the java.lang of Java SE (JDK 1.6 version), phones. This paper presents a methodology (APP2MID) which which has 35 classes and 8 interfaces. J2ME also possesses converts the Java applet into Java MIDlet that can run on many features which are specific and limited to J2ME itself. mobile phones. The conversion methodology is divided in three Table 1 shows the core Java APIs supported by CLDC 1.1 [8]. logical phases and will help the user to create MIDlets from the available Java applets maintaining the original programming TABLE I logic. We illustrate this methodology using a case study. CORE JAVA SE APIS SUPPORTED BY J2ME Package Classes I. INTRODUCTION java.lang Boolean, Byte, Character, Class, Integer, Long,Double, AVA applets have been a one of the popular content Float, Math, Object, Runnable, Runtime, Short, String, J creation format for eLearning. Many leading StringBuffer, System, Thread, Throwable organizations in educational and professional domains java.io ByteArrayInputStream, ByteArrayOutputStream, have created large repositories of educational animations DataInput, DataOutput, DataInputStream, created using JAVA [4]. DataOutputStream, InputStream, OutputStream, InputStreamReader, OutputStreamWriter, PrintStream, Concurrently, mobiles are becoming even more common Reader, Writer and have been having lesser dependencies. The portability java.util Calendar, Date, Enumeration, Hashtable, Random, Stack, and the reach of mobiles is quite more than that of the TimeZone, Vector computers and therefore it is not at all surprising that mobiles are preferred as a medium for educational content dissemination [1], [2]. From the earlier discussion following points are evident: Looking at the large number of Open Source JAVA 1. Available Java applets animations are huge in applets available for the desktops, it is desirable to have a number. methodology to convert those for mobiles in a seamless 2. J2ME does not support all the APIs that are used in manner. In this paper we present one such methodology: Java applet animations creation APP2MID. 3. Re-creation of same animations for mobiles would Java SE (Java standard edition) is used for creating applets be resource intensive. especially for desktops. These applets cannot run on mobile 4. Maintaining the original programming logic of the phones because the APIs used are not supported by mobile animation is critical. phones. For creating applications for mobile phones and Seamless conversion of applets to MIDlets is certainly other handheld devices J2ME (Java 2 Micro edition) desirable. In this paper we present one such methodology. A technology is used [6]. J2ME represents a simpler version of case study is used to illustrate the methodology in detail. Java SE, with a reduced feature set, for the devices with limited memory, small screen sizes, alternative input II. CONVERSION PROCESS: APP2MID methods, and slow processors [7]. The conversion process APP2MID has three logical phases. These phases convert the original Java applet into various Manuscript received August 20, 2009. This work was supported in part by the TTSL IIT Bombay Center of Excellence in Telecommunications formats in a cascading manner to achieve the final goal of (TICET) project of IIT Bombay. creating a MIDlet. The Java applet is not converted directly Kapil Kadam is M. Tech. from Walchand College of Engineering, into MIDlet, as it may create problems for code extraction. Sangli, India and is currently working as Project Engineer at the The first phase converts the Java applet to a XML file for Department of Computer Science and Engineering of IIT Bombay, India. Phone: +91-22-25764987; fax: +91-22-25720022; e-mail: better representation and mapping. The second phase [email protected] transforms this applet XML to a MIDlet XML. The third Sameer Sahasrabudhe is a graduate in Fine arts. He is currently working phase converts the MIDlet XML to a MIDlet. Finally testing as a Project Manager at the Department of Computer Science and Engineering of IIT Bombay, India. Phone: +91-22-25764913; fax: +91-22- is done, to check the quality of the converted MIDlet. Refer 25720022; e-mail: [email protected] Fig. 1. The produced representation allows easy extraction of the semantics of source code and its analysis for further Phase I Phase II Phase III Testing XML Phase transformation. The output of this phase is a valid of Java Applet Applet XML to MIDlet XML the desired MIDlet. Schematic representation of this phase is to Applet MIDlet XML to Java MIDlet shown in Fig. 3. XML Transformation MIDlet Testing C. Conversion Phase-III The third phase has the output of the Phase-II as the input. Fig. 1: Conversion Phases The motivation of this phase is to convert MIDlet XML into Java MIDlet which is the desired final output. In order to achieve this we wrote another class “Converter” A. Conversion Phase-I in the “APP2MIDconverter.java” program mentioned in This phase has Java applet as the input. This applet is Phase-II. This class “Converter” does the MIDlet XML to converted to XML using the available Java to XML converter (Java2XML) [9]. After conversion the applet XML is Input XML to Java Output validated by using a browser (Internet Explorer) [3]. MIDlet XML Converter Java MIDlet Java and XML both are platform independent and XML is Class fully compatible with Java. Standard Java class structure can Converter be well represented in the form of XML tags, so that Java classes, methods, interfaces, packages are processed easily by maintaining the Java programming standards [5]. Fig. 4: Conversion Phase-III Input Java to DTD Valid Java MIDlet conversion. The output of this phase is a desired Java Applet XML Validation Applet XML Converter Java MIDlet. Schematic representation of this phase is shown in Fig. 4. D. Testing Phase Fig. 2 Conversion Phase-I The produced representation allows easy extraction of the Testing is the most important way of assuring (or semantics of source code, its analysis and transformation. controlling) the quality of software or application developed. The third phase delivers the Java MIDlet as final output. The output of this phase is a valid XML of the applet. The resultant Java MIDlet is tested with Sun’s Wireless Schematic representation of this phase is shown in Fig. 2. toolkit emulator [10] by selecting MIDP2.0 & CLDC1.1 APIs, B. Conversion Phase-II that gives the desired output, the actual results are presented The second phase has the output of the Phase-I as in further sections. An error free result leads towards the the input. The motivation of this phase is to transform the actual device testing. Mobile phones like Nokia N72 [12] & applet XML into MIDlet XML. This enable mapping of applet Sony Ericsson W58i [13] were used for testing as they are XML into another XML to obtain the desired MIDlet supported by MIDP 2.0 & CLDC1.1 APIs. structure. III. CASE STUDY Output CONVERSION OF ANIMATIONS IN PROJECT OSCAR MIDlet XML Input XML to XML Project OSCAR stands for Open Source Courseware Applet XML Transformer Animations Repository [11]. This is a project of IIT Bombay Class and hosts over hundred animations, which covers different XMLTraverser DTD th th Validation subjects from standard 7 to standard 12 like Mathematics, Physics, Biology and Chemistry. It also covers Engineering subjects for Undergraduate and Post Graduate studies like Input Networking, Mechanical engineering, etc. Package.xml Valid MIDlet XML Most of the animations from the repository are Java applets, which is suitable for the conversion methodology presented in this paper. We have selected Basic Angles animation from Fig. 3: Conversion Phase-II Mathematics repository as a test case [11]. BasicAngles.java In order to address this we wrote a Java program is a Java applet program which contains the code for the (APP2MIDconverter.java), containing class “XML Traverser” basic angles animation. Fig. 5 shows the output of which does the XML to XML transformation. This created BasicAngles.java applet when executed in applet viewer and Package.xml file which contained XML representation of Fig. 6 shows the small portion of the code. basic MIDlet program structure. The transformed XML is validated in a similar way as mentioned in the Phase-I. portion of the XML applet. As mentioned in the conversion phase-I about standard Java class structure & XML tags, it can be seen from the Fig. 7 that the standard class structure of Java applet (refer Fig. 6) is well represented in the form of XML. For example class “BasicAngles” with visibility attribute “public” (Fig 6) is represented as a XML tag <class name=“BasicAngles” visibility=“public”> in Fig 7. Other code of Java applet was also converted in the form of XML tags. That leads to easy extraction of the semantics of source code, its analysis and transformation as said earlier. B. Phase-II Results Fig 5: Basic angles animation applet As said earlier the input of the second phase is the output of the Phase-I, which is the applet XML (Figure7).