wood burning stoves 2.0*
The moose likes Java Micro Edition and the fly likes problem in connecting floggy using j2me Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "problem in connecting floggy using j2me" Watch "problem in connecting floggy using j2me" New topic
Author

problem in connecting floggy using j2me

majety srikanth
Greenhorn

Joined: Jan 25, 2011
Posts: 14
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)
Thiago Moreira
Greenhorn

Joined: Apr 26, 2004
Posts: 7

The problem seems not be on Floggy. EclipseME is trying to load your Midlet but it is not able to do that.
majety srikanth
Greenhorn

Joined: Jan 25, 2011
Posts: 14
hi Thiago Moreira
Can you please tell me how can I remove this problem ? I configured this project in the usual way(adding third party reference jars ie. floggy persistance jar). In this case, it is giving classnotfoundexception for my midlet - ExampleFloggy.

If I use plugin development way ( i.e downloaded and pasted the floggy plugin jars in eclipse plugins folder, restarted eclipse), it is giving error. Even though the referenced library (i.e persistance jar) is showing the Persistable class in the package explorer view.

Running with locale: English_United States.1252
Running in the minimum security domain
java.lang.NoClassDefFoundError: net/sourceforge/floggy/persistence/Persistable
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.
3407610 bytecodes executed
18 thread switches
1670 classes in the system (including system classes)
17722 dynamic objects allocated (534040 bytes)
3 garbage collections (460124 bytes collected)


Please help me out. I was trying to remove this error from last 3 days.
umc astec
Greenhorn

Joined: Mar 26, 2010
Posts: 2
search on structure midlet.
what Thiago Moreira said is correct.
Thiago Moreira
Greenhorn

Joined: Apr 26, 2004
Posts: 7

Try to run your application without the persistence code (Floggy). If that work okay than uncomment the Floggy code and test again. Keep in mind that to use Floggy on Eclipse you MUST install de plugin http://floggy.sourceforge.net/configuration/eclipse.html

Hope this helps
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in connecting floggy using j2me