Quick question for anybody. After the JDK and J2ME wireless toolkit are installed, is it necessary to download and place the CLDC class files anywhere specific? Many thanks!
It doesn't matter but just make sure when you compile to include the switch -bootclasspath PATH_TO_CLDC_CLASSES like this (assume we are in the base directory of the CLDC/KVM): javac -bootclasspath api/classes.zip Test.java
Thank you for the response. What if I am not using the command line interface? I was just using the J2ME toolkit to build files. It sounds like I need to set environmental variables and what not to accomplish this. If you don't mind, could you dumb this down for me? My understanding is that you: 1) Install the JDK 2) Install the J2ME wireless toolkit 3) Use whatever text editor to create midlets Isn't there a CLDC byte-code preverifer that is installed with the J2ME wireless toolkit? Am I missing some steps? I apologize for being so green at this. Thanks!
Valentin -- I have examined that document...I guess some things still are't explained as completely as I would like (then again I'm a little thick). For example, how do you access the command line? Isn't it mute anyway if you can just click the button (which just automates the task at hand)? Feel free to set me straight on this. Also, I did the HelloWorld thing (a must for newbies) and the compiler spits out these errors: Project "HelloMidlet" loaded Project settings saved Building "HelloMidlet" D:\apps\HelloMidlet\src\HelloMidlet.java:1: 'class' or 'interface' expected {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}} ^ D:\apps\HelloMidlet\src\HelloMidlet.java:1: illegal character: \92 {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}} If you wouldn't mind commenting on these, I would consider you a J2ME saint. Thanks!
Here you go sir: import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class HelloMidlet extends MIDlet implements CommandListener { // Initialize the midlet display variable private Display midletDisplay; // Initialize a variable for the doneCommand private Command doneCommand; public HelloMidlet() { // Retrieve the display from the static display object midletDisplay = Display.getDisplay(this); // Initialize the doneCommand doneCommand = new Command("DONE", Command.SCREEN, 1); } public void startApp() {
// Create the textbox TextBox textBox = new TextBox("Hello Midlet", "Hello Midlet World!!", 256, 0); // Add the done Command to the TextBox textBox.addCommand(doneCommand); // Set the command listener for the textbox to the current midlet textBox.setCommandListener( (CommandListener) this); // Set the current display of the midlet to the textBox screen midletDisplay.setCurrent(textBox); } // PauseApp is used to suspend background activities and release resources public void pauseApp() { } // DestroyApp is used to stop background activities and when midlet is at end of life cycle // public void destroyApp(boolean unconditional) { } // The commandAction method is implemented by this midlet to satisfy CommandListener // interface and handle the done action public void commandAction(Command command, Displayable screen) { // If the command is the doneCommand if (command == doneCommand) { // Call the destroyApp method destroyApp(false); // Notify the midlet platform that the midlet has completed notifyDestroyed(); } } }
Here you go sir tsk tsk tsk... no "sir" please, Val will be fine. I tried your code and it compiled fine AFTER I added the destroyApp(boolean b) method in it. You have to do that since you are subclassing MIDlet which is abstract. Try it and let me know.
I don't think you can do that. At least, not with Sun's wireless toolkit.. Maybe someone else has a trick... But you still can execute some commands in a terminal or something...