Hi,
I am new to J2me and floggy. I have included floggy-persistence-framework.jar in eclipseME buildpath. Still, I am also getting the same error. I saw the floggy FAQ. But, I am not able to change either of the lines from
Date dateIn = new Date(); // if I try to change Class.forname - it is giving error
Date dateOut = new Date(tfield.getString(), Integer.parseInt(tfieldN
.getString()));
to
Class personClass= Class.forName("Date");
In EclipseME it is showing, it is working in CLDC1.1 only. still no use.
Please kindly let me know the solution. thanks for your help.
Here are the programs
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
//import net.sourceforge.floggy.persistence.FloggyException;
import net.sourceforge.floggy.persistence.PersistableManager;
public class ExampleFloggy extends MIDlet implements CommandListener {
private TextField tfield;
private Command savecmd;
private Display display;
private Form form;
private TextField tfieldN;
private Command exitcmd;
public ExampleFloggy() {
System.out.println("inside constructor");
tfield = new TextField("name:", "", 15, TextField.ANY);
tfieldN = new TextField("age:", "0", 15, TextField.NUMERIC);
savecmd = new Command("save", "save file", Command.ITEM, 0);
exitcmd = new Command("exit","exit",Command.EXIT,1);
form = new Form("Floggy example.");
form.append(tfield);
form.append(tfieldN);
form.addCommand(savecmd);
form.addCommand(exitcmd);
form.setCommandListener(this);
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
notifyDestroyed();
}
protected void pauseApp() {
}
protected void startApp() throws MIDletStateChangeException {
System.out.println("inside startapp");
display = Display.getDisplay(this);
display.setCurrent(form);
}
public void commandAction(Command cmd, Displayable arg1) {
System.out.println("inside commandaction");
if (cmd == savecmd) {
Date dateOut = new Date(tfield.getString(), Integer.parseInt(tfieldN
.getString()));
int id;
try {
id = PersistableManager.getInstance().save(dateOut);
Date dateIn = new Date();
PersistableManager.getInstance().load(dateIn, id);
form.append(dateIn.toString());
} catch (Exception e) {
e.printStackTrace();
}
}else if (cmd==exitcmd){
try {
destroyApp(true);
} catch (MIDletStateChangeException e) {
e.printStackTrace();
}
}
}
}
########################################
import net.sourceforge.floggy.persistence.Persistable;
public class Date implements Persistable {
private
String name;
private int age;
private transient int num;
public Date() {
}
public Date(String name, int age) {
this.name = name;
this.age = age;
}
public String toString() {
return "";
}
}
###################################
error
######################################
Running with locale: English_United States.1252
Running in the minimum security domain
java.lang.ClassNotFoundException: ExampleFloggy
at com.sun.midp.midlet.MIDletState.createMIDlet(+29)
at com.sun.midp.midlet.Scheduler.schedule(+52)
at com.sun.midp.main.Main.runLocalClass(+28)
at com.sun.midp.main.Main.main(+80)
Execution completed.
3348452 bytecodes executed
20
thread switches
1667 classes in the system (including system classes)
17251 dynamic objects allocated (514248 bytes)
1 garbage collections (0 bytes collected)