SlideShare a Scribd company logo
1 of 29
Mobile Programming with J2ME
               By Oluwatosin Adesanya
Lesson 01:
Basic Java Programming
Java is ...
     •   A Pure OOP Language
     •   A Hybrid Programming Language
     •   First Compiled and Interpreted
     •   Runs on a JVM (Java Virtual Machine)



                      Byte Code




Source                                          Object
 Code                                           Code
Getting Started

• JDK (Java Development Kit)
• Editor (Notepad) OR ...
• Integrated Development Environment (Netbeans, Eclipse,
  JCreator etc.)
Setting Up Java

• Install the JDK
• The JDK Sits in C:Program FilesJavajdk1.6.0
• Set the PATH Environmental Variable (How?)
Setting the PATH Environmental Variable

Open your Systems Property: choose Advanced System Settings, Click
the Environmental Variable Button on the Dialog that shows Up
Setting the PATH Environmental Variable

Scroll and Select Path , Click Edit Button
Setting the PATH Environmental Variable

Append the current path with the path to the Java bin folder
Running Java

• Save your Java source code as a .java file
• Use the javac Command to compile your source codes (.java files)
  e.g javac Result.java
• A .class file is generated called a bytecode
• Use java Command to run the .class file e.g java Result
• Do not add .class when compiling




      Source                                          Object
                  javac     Byte Code     java
       Code                                           Code
The Structure of a Java Program

• Java Programs are made up of classes
• Classes are made up of methods
• Java existing (ready-made) classes are found in the Java Class
  Libraries (Also Called Java APIs)
• Execution of Java programs begin at the main method
A Simple Java Program


public class HelloWorld {
  public static void main(String[] args) {
      System.out.println("Hello World!");
  }
}
Classes and Objects

• A Class is like a factory from which Objects are churned Out.

   Example
   Class Car could produce objects Volkswagen bettles, Toyota Camri,
   Peugeout 306

   An Object is a model of the Real World and has
   States (Or Properties) and
   Behaviours (Or Actions)

   Example
   Object Car States are Color, Speed, Size, Plate Licence No, Cost
   Behaviours are Start, Stop, Accelerate, Fuel, Open Door, etc.
Creating a Class

Use the class Keyword

Example
public class HelloWorld {
          .
          .
          .
    }

Do NOT Forget!
Name your java file ClassName.java
Adding States (Properties)

• States in Java are simply variables (Otherwise called fields)

   Example

   public class PaySlip {
       int numdone;
       String name;
   }


   Observe?!
   Every Line of Java code ends with a semicolon (;)

  int,float, double,
  boolean, char … are Java Primitive Types
Adding Behaviours (Methods)

•   Methods are functions that control states or fields or variables. They
    change the state of an object.

    Example

    public class PaySlip {
        int numdone;
        String name;

         public double getPay() {
               return 40.00 * numdone;
         }
                                                         Method getPay()
    }


    Guess What? We already have a working Java Class!
Using Our Class PaySlip

We implement another tester class which
contains the main method.


public class TestPaySlip {
      public static void main(String[] args){
            PaySlip opay=new PaySlip();
            System.out.println("n"+opay.getPay());
      }
}
Constructors

•   Initializes the Object after memory allocation
•   Takes the same name as the Class
•   May accept parameters OR... may not
•   Every Class has a default constructor that accepts no parameter
•   Has No Return Type
•   Can be Overloaded (there can be multiple Constructors)
Constructors
public class PaySlip {
   int numdone;
   String name;

    public PaySlip(int numdone, String name) {
        this.numdone=numdone; this.name=name;
    }

    public PaySlip(){
        name=“Nobody”;
        numdone=0;
    }

    public double getPay() {
        return 40.00 * numdone;
    }
}
Sorry...



• Confused?
• Questions?
Lesson 02:
Java 2 Micro Edition(J2ME)
J2ME is ...

•   Java for small devices
•   Divided into Configurations, Profiles and Optional APIs

    Configurations, Profiles and Optional APIs combined together make up
    a stack

    Configurations: Specifies a JVM. We have CDC and CLDC

    CLDC (Connected Limited Device Configuration) is designed for
    devices with limited memory, displays, battery power and inputs.

    Profiles: Layered on top of CLDC and adds APIs for specific devices.
    We have MIDP, PDAP and Personal Profiles

    MIDP (Mobile Information Device Profile) has characteristics that makes
    most low end phones and PDAs fit in. J2ME is covered by MIDPs
Anatomy of MIDP Apps
MIDP Apps are ...

• Called MIDlets
• Portable
• Secured
• represented by instances of
  javax.microedition.midlet.MIDlet class
• Distributed as JAR (Java Archive) files along with a MANIFEST file
  and an Application Descriptor File (.jad file)
• Reduced to small sizes before distribution by an Obfuscator




    Popular J2ME Apps: Opera Mini, 2go, Go Bible
The MIDlet Life Cycle
Shall We Create a MIDlet?

package com.thinkit2ru;

import javax.microedition.midlet.*;

public class Metric extends MIDlet {

    public void startApp() {
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }
}
Remember the Constructor?
package com.thinkit2ru;

import javax.microedition.midlet.*;

public class Metric extends MIDlet {

    public Metric() {          The Contructor:
    }                          Build Components Here
    public void startApp() {
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }
}
You need to Know...

•   Primitive data types
•   String Manipulation
•   Control Statements
•   Arrays and other data structures
•   GUI Design
•   Database Connectivity
•   Multithreading
•   Ethics and Conventions
Questions Please...
System.out.println(“Thank You”);

More Related Content

What's hot

Java tutorials
Java tutorialsJava tutorials
Java tutorials
saryu2011
 
Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016
Manuel Fomitescu
 

What's hot (20)

Core Java Tutorial
Core Java TutorialCore Java Tutorial
Core Java Tutorial
 
Core java
Core javaCore java
Core java
 
Core java
Core java Core java
Core java
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
 
1_JavIntro
1_JavIntro1_JavIntro
1_JavIntro
 
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
Collection Framework in Java | Generics | Input-Output in Java | Serializatio...
 
Java tutorials
Java tutorialsJava tutorials
Java tutorials
 
Java tutorials
Java tutorialsJava tutorials
Java tutorials
 
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
 
Java 201 Intro to Test Driven Development in Java
Java 201   Intro to Test Driven Development in JavaJava 201   Intro to Test Driven Development in Java
Java 201 Intro to Test Driven Development in Java
 
Java 101 Intro to Java Programming
Java 101 Intro to Java ProgrammingJava 101 Intro to Java Programming
Java 101 Intro to Java Programming
 
Basic java for Android Developer
Basic java for Android DeveloperBasic java for Android Developer
Basic java for Android Developer
 
Synapseindia reviews.odp.
Synapseindia reviews.odp.Synapseindia reviews.odp.
Synapseindia reviews.odp.
 
Java for the Beginners
Java for the BeginnersJava for the Beginners
Java for the Beginners
 
Core Java introduction | Basics | free course
Core Java introduction | Basics | free course Core Java introduction | Basics | free course
Core Java introduction | Basics | free course
 
New Features Of JDK 7
New Features Of JDK 7New Features Of JDK 7
New Features Of JDK 7
 
Core java Basics
Core java BasicsCore java Basics
Core java Basics
 
Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java
 
Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016
 
Introduction to java 101
Introduction to java 101Introduction to java 101
Introduction to java 101
 

Similar to Java Programming and J2ME: The Basics

JavaClassPresentation
JavaClassPresentationJavaClassPresentation
JavaClassPresentation
juliasceasor
 
Fundamentals of java --- version 2
Fundamentals of java --- version 2Fundamentals of java --- version 2
Fundamentals of java --- version 2
Uday Sharma
 

Similar to Java Programming and J2ME: The Basics (20)

oop unit1.pptx
oop unit1.pptxoop unit1.pptx
oop unit1.pptx
 
CS8392 OOP
CS8392 OOPCS8392 OOP
CS8392 OOP
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
 
Pj01 2-install java and write first java program
Pj01 2-install java and write first java programPj01 2-install java and write first java program
Pj01 2-install java and write first java program
 
Module 1.pptx
Module 1.pptxModule 1.pptx
Module 1.pptx
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
ITFT - Java Coding
ITFT - Java CodingITFT - Java Coding
ITFT - Java Coding
 
Java introduction
Java introductionJava introduction
Java introduction
 
JavaClassPresentation
JavaClassPresentationJavaClassPresentation
JavaClassPresentation
 
Java Programming concept
Java Programming concept Java Programming concept
Java Programming concept
 
Letest
LetestLetest
Letest
 
02 basic java programming and operators
02 basic java programming and operators02 basic java programming and operators
02 basic java programming and operators
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
Fundamentals of java --- version 2
Fundamentals of java --- version 2Fundamentals of java --- version 2
Fundamentals of java --- version 2
 
Object Oriented Programming-JAVA
Object Oriented Programming-JAVAObject Oriented Programming-JAVA
Object Oriented Programming-JAVA
 
OOP with Java
OOP with JavaOOP with Java
OOP with Java
 
Java part 1
Java part 1Java part 1
Java part 1
 
Java
JavaJava
Java
 
Introduction to java programming part 1
Introduction to java programming   part 1Introduction to java programming   part 1
Introduction to java programming part 1
 

Recently uploaded

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
MateoGardella
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Recently uploaded (20)

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 

Java Programming and J2ME: The Basics

  • 1. Mobile Programming with J2ME By Oluwatosin Adesanya
  • 2. Lesson 01: Basic Java Programming
  • 3. Java is ... • A Pure OOP Language • A Hybrid Programming Language • First Compiled and Interpreted • Runs on a JVM (Java Virtual Machine) Byte Code Source Object Code Code
  • 4. Getting Started • JDK (Java Development Kit) • Editor (Notepad) OR ... • Integrated Development Environment (Netbeans, Eclipse, JCreator etc.)
  • 5. Setting Up Java • Install the JDK • The JDK Sits in C:Program FilesJavajdk1.6.0 • Set the PATH Environmental Variable (How?)
  • 6. Setting the PATH Environmental Variable Open your Systems Property: choose Advanced System Settings, Click the Environmental Variable Button on the Dialog that shows Up
  • 7. Setting the PATH Environmental Variable Scroll and Select Path , Click Edit Button
  • 8. Setting the PATH Environmental Variable Append the current path with the path to the Java bin folder
  • 9. Running Java • Save your Java source code as a .java file • Use the javac Command to compile your source codes (.java files) e.g javac Result.java • A .class file is generated called a bytecode • Use java Command to run the .class file e.g java Result • Do not add .class when compiling Source Object javac Byte Code java Code Code
  • 10. The Structure of a Java Program • Java Programs are made up of classes • Classes are made up of methods • Java existing (ready-made) classes are found in the Java Class Libraries (Also Called Java APIs) • Execution of Java programs begin at the main method
  • 11. A Simple Java Program public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } }
  • 12. Classes and Objects • A Class is like a factory from which Objects are churned Out. Example Class Car could produce objects Volkswagen bettles, Toyota Camri, Peugeout 306 An Object is a model of the Real World and has States (Or Properties) and Behaviours (Or Actions) Example Object Car States are Color, Speed, Size, Plate Licence No, Cost Behaviours are Start, Stop, Accelerate, Fuel, Open Door, etc.
  • 13. Creating a Class Use the class Keyword Example public class HelloWorld { . . . } Do NOT Forget! Name your java file ClassName.java
  • 14. Adding States (Properties) • States in Java are simply variables (Otherwise called fields) Example public class PaySlip { int numdone; String name; } Observe?! Every Line of Java code ends with a semicolon (;) int,float, double, boolean, char … are Java Primitive Types
  • 15. Adding Behaviours (Methods) • Methods are functions that control states or fields or variables. They change the state of an object. Example public class PaySlip { int numdone; String name; public double getPay() { return 40.00 * numdone; } Method getPay() } Guess What? We already have a working Java Class!
  • 16. Using Our Class PaySlip We implement another tester class which contains the main method. public class TestPaySlip { public static void main(String[] args){ PaySlip opay=new PaySlip(); System.out.println("n"+opay.getPay()); } }
  • 17. Constructors • Initializes the Object after memory allocation • Takes the same name as the Class • May accept parameters OR... may not • Every Class has a default constructor that accepts no parameter • Has No Return Type • Can be Overloaded (there can be multiple Constructors)
  • 18. Constructors public class PaySlip { int numdone; String name; public PaySlip(int numdone, String name) { this.numdone=numdone; this.name=name; } public PaySlip(){ name=“Nobody”; numdone=0; } public double getPay() { return 40.00 * numdone; } }
  • 20. Lesson 02: Java 2 Micro Edition(J2ME)
  • 21. J2ME is ... • Java for small devices • Divided into Configurations, Profiles and Optional APIs Configurations, Profiles and Optional APIs combined together make up a stack Configurations: Specifies a JVM. We have CDC and CLDC CLDC (Connected Limited Device Configuration) is designed for devices with limited memory, displays, battery power and inputs. Profiles: Layered on top of CLDC and adds APIs for specific devices. We have MIDP, PDAP and Personal Profiles MIDP (Mobile Information Device Profile) has characteristics that makes most low end phones and PDAs fit in. J2ME is covered by MIDPs
  • 23. MIDP Apps are ... • Called MIDlets • Portable • Secured • represented by instances of javax.microedition.midlet.MIDlet class • Distributed as JAR (Java Archive) files along with a MANIFEST file and an Application Descriptor File (.jad file) • Reduced to small sizes before distribution by an Obfuscator Popular J2ME Apps: Opera Mini, 2go, Go Bible
  • 25. Shall We Create a MIDlet? package com.thinkit2ru; import javax.microedition.midlet.*; public class Metric extends MIDlet { public void startApp() { } public void pauseApp() { } public void destroyApp(boolean unconditional) { } }
  • 26. Remember the Constructor? package com.thinkit2ru; import javax.microedition.midlet.*; public class Metric extends MIDlet { public Metric() { The Contructor: } Build Components Here public void startApp() { } public void pauseApp() { } public void destroyApp(boolean unconditional) { } }
  • 27. You need to Know... • Primitive data types • String Manipulation • Control Statements • Arrays and other data structures • GUI Design • Database Connectivity • Multithreading • Ethics and Conventions