wood burning stoves 2.0*
The moose likes Java Micro Edition and the fly likes Where do the CLDC class files need to be placed? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Where do the CLDC class files need to be placed?" Watch "Where do the CLDC class files need to be placed?" New topic
Author

Where do the CLDC class files need to be placed?

Jason Long
Greenhorn

Joined: Dec 16, 2001
Posts: 17
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!
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
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


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Jason Long
Greenhorn

Joined: Dec 16, 2001
Posts: 17
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 Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Jason,
I think a good idea would be to read the Java Wireless Toolkit User's Guide.
Let us know if you still have doubts after that...
Jason Long
Greenhorn

Joined: Dec 16, 2001
Posts: 17
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!
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Jason,
could you please post the code for HelloMidlet, please?
Jason Long
Greenhorn

Joined: Dec 16, 2001
Posts: 17
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();
}
}
}
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
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.
Jason Long
Greenhorn

Joined: Dec 16, 2001
Posts: 17
Val -- thanks with your help, it is much appreciated. I finally got that sucker working. Thanks a bunch!
Jason Long
Greenhorn

Joined: Dec 16, 2001
Posts: 17
One question though. How do access the command line to enter commands through the toolkit? I can not find any info on that.
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
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...
Jason Long
Greenhorn

Joined: Dec 16, 2001
Posts: 17
Thanks for your response. I really appreciate your help!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Where do the CLDC class files need to be placed?