Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java classes and J2ME classes

 
Daniel Foord
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there
I've recently written a program in "normal" Java, just to get the feel for it.
However my real aim is to write the program so it runs on a mobile.

My problem is, and I feared as much, when I simply copy and paste the code from a standard Java project/package to the J2ME project it can't find most of the classes.

My program uses the following classes:

import java.lang.System.out;
import java.util.Scanner;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Random;
import java.io.LineNumberReader;



But with the exception of the IOException the Micro Edition can't find any of them.

How do I find out what their equivalents are (if there are any)?
It is important for me to read in a file (io.File), count the lines (io.LineNumber.Reader), turn the contents into an array of arrays(util.ArrayList), display one of the array items (System.out), get user input (util.Scanner).

For example is there a Micro Edition class = io.LineNumberReader?
Or am I going to have to reinvent the wheel?

Thanks very much in advance.

Dan
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
J2ME is their own subset of APIs. Some are just simpler versions of the J2SE, but no IO classes. It has the Generic Connection Framework to get connections, and not all devices will implement all the possible types of Connection objects.

For use input you use the J2ME microedition lcdui package to create a TextField.

If you haven't done so yet, download the Wireless Toolkit from Sun, and in that installation is the JavaDocs for the J2ME APIs, go into MIDP and see what you have and what you don't.

J2Se and J2ME are two different paradigms.

Mark
 
Casper Maxwell
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I reccomend you to think two APIs different and work on them separately (possibily in parallel). Here is a link to get started:

Getting Started with Java ME
http://www.java-tips.org/content/view/95/39/
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic