mfriend
 
NEC
Japanese Chinese
Information Technical Lecture Model Information FAQ BBS Sitemap Contact TOP
 
Technical Lecture
Beginners'
Java Lecture

▼First
▼Second
▼Third
▼Fourth
▼Fifth
▼Sixth
▼Seventh
▼Eighth
▼Ninth
▼Tenth
▼Eleventh
▼Twelfth

Advanced
Java Lecture

▼First
▼Second
▼Third
▼Fourth
▼Fifth
▼Sixth
▼Seventh
▼Eighth

■LECTURE TOP

Running Apps on Mobile Phones


♦1. The Java framework

  Nikki, do you remember how you compiled a Java program last time?
  Yeah. I compiled the program before running it on the emulator.
  Well today I want to talk about compiling from the standpoint of the programming framework that Java gives us.


♦1.1. Interpreters and compilers

  Source code we write in Java and other programming languages is translated by interpreters and compilers into machine language.
  Machine language?
  Yes. Source code in a programming language cannot be understood by computers without modification. That's why we use interpreters and compilers to translate it into machine language so computers can understand it.


  With interpreters, each segment of source code in a programming language is translated and executed. Compilers, on the other hand, just translate all the source code from programming language into machine language to prepare them. In that format, the programs can be read and executed by computers. This process of using a compiler to translate source code in programming language into machine language is called compiling.
  So with interpreters, programs are translated and then executed? It seems like compilers would take longer to translate the whole program to prepare it for execution.
  That's right. It's true that compilers must translate all the source code initially. But once the program is fully translated, it can be executed faster than it would take an



♦1.2. The Java framework

  Now that you understand compilers and interpreters, I want to talk about Java. In fact, using Java involves both a compiler and interpreter.
  Both of them?
  Yes. Java source code is translated by a Java compiler into bytecode. This bytecode is interpreted by a Java virtual machine one step at a time and executed.
  Why go through all that trouble? All we need is a compiler to convert it to an executable format.
  This lets us produce cross-platform programs. In the Java framework, we set up a virtual computer (called a Java virtual machine) inside real computers and devices. It ensures that we can run the same program regardless of the operating system.


♦2. JAR files and JAD files

♦2.1. The format for transferring files

  Nikki, do you remember using the emulator to check the operation of your compiled class file?
  Yes, I do.
  Well for mobile phones to run applications, they can't just use the class files.
  They can't? So what do they need to run them?
  To run Java programs on handsets, we must prepare JAR and JAD files for the programs.
  JAR files? And JAD files?
  That's right. JAR files are archives that bring together class files, graphics, and sounds. You can tell that JAR files simplify program distribution.
  Because it's easier to distribute a single set of files than all the files individually, right?
  Exactly. JAD files, on the other hand, just describe the mobile apps. (JAD is short for Java application descriptor.) They give basic information including the application name and an explanation.


♦2.2. Naming JAR files

  Now let's create the JAR and JAD files for the helloworld program you wrote last time.
  All right.


  First, you must name the JAR file you'll create. In the Options menu of the emulator, choose MIDlet suite...


  This is where you'll enter the name of the JAR file to be created. Enter helloworld in the JAR file name field and click OK.

♦2.3. Compiling


  Now you're ready to compile the files. In the Tools menu, click Compile.
  So if the Message Panel displays Compilation Completed, compilation was successful, right?
  That's right!




copyright(c) NEC Corporation 2003