• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Where do the CLDC class files need to be placed?

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Jason Long
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jason,
could you please post the code for HelloMidlet, please?
 
Jason Long
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Val -- thanks with your help, it is much appreciated. I finally got that sucker working. Thanks a bunch!
 
Jason Long
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your response. I really appreciate your help!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic