Olá… eu de novo… de repente esse erro… não consigo fazer funcionar… será que é um problema nos classpath (já vão enteder)
mainMidlet.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
* @author Ricardo
*/
public class mainMidlet extends MIDlet implements CommandListener {
private boolean midletPaused = false;
//<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|
private Form formCadastro;
private TextField tfNome;
private TextField tfEmail;
private DateField dfNasc;
private Alert alertCadastro;
private Command exitCommand;
private Command okCommand;
//</editor-fold>//GEN-END:|fields|0|
/**
* The mainMidlet constructor.
*/
public mainMidlet() {
}
//<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|
//</editor-fold>//GEN-END:|methods|0|
//<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">//GEN-BEGIN:|0-initialize|0|0-preInitialize
/**
* Initializes the application.
* It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.
*/
private void initialize () {//GEN-END:|0-initialize|0|0-preInitialize
// write pre-initialize user code here
//GEN-LINE:|0-initialize|1|0-postInitialize
// write post-initialize user code here
}//GEN-BEGIN:|0-initialize|2|
//</editor-fold>//GEN-END:|0-initialize|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">//GEN-BEGIN:|3-startMIDlet|0|3-preAction
/**
* Performs an action assigned to the Mobile Device - MIDlet Started point.
*/
public void startMIDlet () {//GEN-END:|3-startMIDlet|0|3-preAction
// write pre-action user code here
switchDisplayable (null, getFormCadastro ());//GEN-LINE:|3-startMIDlet|1|3-postAction
// write post-action user code here
}//GEN-BEGIN:|3-startMIDlet|2|
//</editor-fold>//GEN-END:|3-startMIDlet|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">//GEN-BEGIN:|4-resumeMIDlet|0|4-preAction
/**
* Performs an action assigned to the Mobile Device - MIDlet Resumed point.
*/
public void resumeMIDlet () {//GEN-END:|4-resumeMIDlet|0|4-preAction
// write pre-action user code here
//GEN-LINE:|4-resumeMIDlet|1|4-postAction
// write post-action user code here
}//GEN-BEGIN:|4-resumeMIDlet|2|
//</editor-fold>//GEN-END:|4-resumeMIDlet|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">//GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch
/**
* Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.
* @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately
* @param nextDisplayable the Displayable to be set
*/
public void switchDisplayable (Alert alert, Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch
// write pre-switch user code here
Display display = getDisplay ();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch
if (alert == null) {
display.setCurrent (nextDisplayable);
} else {
display.setCurrent (alert, nextDisplayable);
}//GEN-END:|5-switchDisplayable|1|5-postSwitch
// write post-switch user code here
}//GEN-BEGIN:|5-switchDisplayable|2|
//</editor-fold>//GEN-END:|5-switchDisplayable|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">//GEN-BEGIN:|7-commandAction|0|7-preCommandAction
/**
* Called by a system to indicated that a command has been invoked on a particular displayable.
* @param command the Command that was invoked
* @param displayable the Displayable where the command was invoked
*/
public void commandAction (Command command, Displayable displayable) {//GEN-END:|7-commandAction|0|7-preCommandAction
// write pre-action user code here
if (displayable == formCadastro) {//GEN-BEGIN:|7-commandAction|1|21-preAction
if (command == exitCommand) {//GEN-END:|7-commandAction|1|21-preAction
// write pre-action user code here
exitMIDlet ();//GEN-LINE:|7-commandAction|2|21-postAction
// write post-action user code here
} else if (command == okCommand) {//GEN-LINE:|7-commandAction|3|23-preAction
// write pre-action user code here
switchDisplayable (getAlertCadastro (), getFormCadastro ());//GEN-LINE:|7-commandAction|4|23-postAction
// write post-action user code here
}//GEN-BEGIN:|7-commandAction|5|7-postCommandAction
}//GEN-END:|7-commandAction|5|7-postCommandAction
// write post-action user code here
}//GEN-BEGIN:|7-commandAction|6|
//</editor-fold>//GEN-END:|7-commandAction|6|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: formCadastro ">//GEN-BEGIN:|14-getter|0|14-preInit
/**
* Returns an initiliazed instance of formCadastro component.
* @return the initialized component instance
*/
public Form getFormCadastro () {
if (formCadastro == null) {//GEN-END:|14-getter|0|14-preInit
// write pre-init user code here
formCadastro = new Form ("Cadastro", new Item[] { getTfNome (), getTfEmail (), getDfNasc () });//GEN-BEGIN:|14-getter|1|14-postInit
formCadastro.addCommand (getExitCommand ());
formCadastro.addCommand (getOkCommand ());
formCadastro.setCommandListener (this);//GEN-END:|14-getter|1|14-postInit
// write post-init user code here
}//GEN-BEGIN:|14-getter|2|
return formCadastro;
}
//</editor-fold>//GEN-END:|14-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: tfNome ">//GEN-BEGIN:|15-getter|0|15-preInit
/**
* Returns an initiliazed instance of tfNome component.
* @return the initialized component instance
*/
public TextField getTfNome () {
if (tfNome == null) {//GEN-END:|15-getter|0|15-preInit
// write pre-init user code here
tfNome = new TextField ("Nome", null, 32, TextField.ANY);//GEN-LINE:|15-getter|1|15-postInit
// write post-init user code here
}//GEN-BEGIN:|15-getter|2|
return tfNome;
}
//</editor-fold>//GEN-END:|15-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: tfEmail ">//GEN-BEGIN:|16-getter|0|16-preInit
/**
* Returns an initiliazed instance of tfEmail component.
* @return the initialized component instance
*/
public TextField getTfEmail () {
if (tfEmail == null) {//GEN-END:|16-getter|0|16-preInit
// write pre-init user code here
tfEmail = new TextField ("E-mail", null, 32, TextField.ANY);//GEN-LINE:|16-getter|1|16-postInit
// write post-init user code here
}//GEN-BEGIN:|16-getter|2|
return tfEmail;
}
//</editor-fold>//GEN-END:|16-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: dfNasc ">//GEN-BEGIN:|17-getter|0|17-preInit
/**
* Returns an initiliazed instance of dfNasc component.
* @return the initialized component instance
*/
public DateField getDfNasc () {
if (dfNasc == null) {//GEN-END:|17-getter|0|17-preInit
// write pre-init user code here
dfNasc = new DateField ("Data de Nascimento", DateField.DATE);//GEN-BEGIN:|17-getter|1|17-postInit
dfNasc.setDate (new java.util.Date (System.currentTimeMillis ()));//GEN-END:|17-getter|1|17-postInit
// write post-init user code here
}//GEN-BEGIN:|17-getter|2|
return dfNasc;
}
//</editor-fold>//GEN-END:|17-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: alertCadastro ">//GEN-BEGIN:|18-getter|0|18-preInit
/**
* Returns an initiliazed instance of alertCadastro component.
* @return the initialized component instance
*/
public Alert getAlertCadastro () {
if (alertCadastro == null) {//GEN-END:|18-getter|0|18-preInit
// write pre-init user code here
alertCadastro = new Alert ("Cadastro Salvo!");//GEN-BEGIN:|18-getter|1|18-postInit
alertCadastro.setTimeout (Alert.FOREVER);//GEN-END:|18-getter|1|18-postInit
// write post-init user code here
}//GEN-BEGIN:|18-getter|2|
return alertCadastro;
}
//</editor-fold>//GEN-END:|18-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand ">//GEN-BEGIN:|20-getter|0|20-preInit
/**
* Returns an initiliazed instance of exitCommand component.
* @return the initialized component instance
*/
public Command getExitCommand () {
if (exitCommand == null) {//GEN-END:|20-getter|0|20-preInit
// write pre-init user code here
exitCommand = new Command ("Sair", Command.EXIT, 0);//GEN-LINE:|20-getter|1|20-postInit
// write post-init user code here
}//GEN-BEGIN:|20-getter|2|
return exitCommand;
}
//</editor-fold>//GEN-END:|20-getter|2|
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand ">//GEN-BEGIN:|22-getter|0|22-preInit
/**
* Returns an initiliazed instance of okCommand component.
* @return the initialized component instance
*/
public Command getOkCommand () {
if (okCommand == null) {//GEN-END:|22-getter|0|22-preInit
// write pre-init user code here
okCommand = new Command ("Salvar", Command.OK, 0);//GEN-LINE:|22-getter|1|22-postInit
// write post-init user code here
}//GEN-BEGIN:|22-getter|2|
return okCommand;
}
//</editor-fold>//GEN-END:|22-getter|2|
/**
* Returns a display instance.
* @return the display instance.
*/
public Display getDisplay() {
return Display.getDisplay(this);
}
/**
* Exits MIDlet.
*/
public void exitMIDlet() {
switchDisplayable(null, null);
destroyApp(true);
notifyDestroyed();
}
/**
* Called when MIDlet is started.
* Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
*/
public void startApp() {
if (midletPaused) {
resumeMIDlet();
} else {
initialize();
startMIDlet();
}
midletPaused = false;
}
/**
* Called when MIDlet is paused.
*/
public void pauseApp() {
midletPaused = true;
}
/**
* Called to signal the MIDlet to terminate.
* @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
*/
public void destroyApp(boolean unconditional) {
}
}
e daí mesmo compilando (isso não dá erro) dá erro no console do netbeans (após pedir para rodar SHIFT-F6) assim:
Copying 1 file to C:\Users\Ricardo\Documents\NetBeansProjects\formulario\dist\nbrun2105600471731673436
Copying 1 file to C:\Users\Ricardo\Documents\NetBeansProjects\formulario\dist\nbrun2105600471731673436
Jad URL for OTA execution: http://localhost:8082/servlet/org.netbeans.modules.mobility.project.jam.JAMServlet/C%3A/Users/Ricardo/Documents/NetBeansProjects/formulario/dist//formulario.jad
Starting emulator in execution mode
C:\Users\Ricardo\Documents\NetBeansProjects\formulario\nbproject\build-impl.xml:915: Execution failed with error code 1.
FALHA NA CONSTRUÇÃO (tempo total: 3 segundos)
a linha 915 do build-impl.xml é essa:
" <nb-run jadfile="${dist.dir}/${dist.jad}" jarfile="${dist.dir}/${dist.jar}" jadurl="${dist.jad.url}" device="${platform.device}" platformhome="${platform.home}" platformtype="${platform.type}" execmethod="${run.method}" securitydomain="${evaluated.run.security.domain}" commandline="${platform.runcommandline}" classpath="${platform.bootclasspath}:${dist.dir}/${dist.jar}" cmdoptions="${run.cmd.options}"/>"
O projeto está CLDC 1.0 E MIDP 2.0 e o emulador é Clamshellcldcphone1.
Será que tem haver com algum classpath faltando ou alguma conf no NetBeans?
Desde já obrigado e abraços.
Ricardo