Page 1 of 2 12 LastLast
Results 1 to 20 of 21

Thread: Compilin prob

  1. #1
    imu09 is offline Member
    Join Date
    Apr 2011
    Posts
    16
    Rep Power
    0

    Question Compilin prob

    Hey i'm a java newbie, and i'm making my 1st java ME app with Netbeans 6.8. I finished coding my app, and I compiled it into one single jar file, but when I try running it on my phone, I get the error: Java/lang/classnotfoundextension. Netbeans does not show any errors in the code, so I think it didn't compile the jar properly (or something). Please help.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default

    Post the code, in code tags -- [code]CODE[/code] will display as
    Java Code:
    CODE
    db

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default

    Also, copy correctly. The error certainly wasn't Java/lang/classnotfoundextension.

    db

  4. #4
    imu09 is offline Member
    Join Date
    Apr 2011
    Posts
    16
    Rep Power
    0

    Default

    I should post the code of my app here?
    The one I made in netbeans?

  5. #5
    imu09 is offline Member
    Join Date
    Apr 2011
    Posts
    16
    Rep Power
    0

    Default

    I think I may have messed up the code. Workin on it...

  6. #6
    imu09 is offline Member
    Join Date
    Apr 2011
    Posts
    16
    Rep Power
    0

    Default

    Java Code:
    package coolSMS;
    
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import org.netbeans.microedition.lcdui.SplashScreen;
    import org.netbeans.microedition.lcdui.WaitScreen;
    import org.netbeans.microedition.lcdui.wma.SMSComposer;
    import org.netbeans.microedition.util.SimpleCancellableTask;
    
    public class coolSMS extends MIDlet implements CommandListener {
    
        private boolean midletPaused = false;
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">                      
        private Command exitCommand;
        private Command exitCommand1;
        private SplashScreen splashScreen;
        private SMSComposer smsComposer;
        private WaitScreen waitScreen;
        private Alert alert;
        private Alert alert1;
        private SimpleCancellableTask task;
        //</editor-fold>                    
    
        public coolSMS() {
        }
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Methods ">                       
        //</editor-fold>                     
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">                                           
    
        private void initialize() {                                         
            // write pre-initialize user code here
                                               
            // write post-initialize user code here
        }                            
        //</editor-fold>                          
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">                                        
    
        public void startMIDlet() {                                      
            // write pre-action user code here
            switchDisplayable(null, getSplashScreen());                                        
            // write post-action user code here
        }                             
        //</editor-fold>                           
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">                                         
    
        public void resumeMIDlet() {                                       
            // write pre-action user code here
                                             
            // write post-action user code here
        }                              
        //</editor-fold>                            
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">                                              
    
        public void switchDisplayable(Alert alert, Displayable nextDisplayable) {                                            
            // write pre-switch user code here
            Display display = getDisplay();                                               
            if (alert == null) {
                display.setCurrent(nextDisplayable);
            } else {
                display.setCurrent(alert, nextDisplayable);
            }                                             
            // write post-switch user code here
        }                                   
        //</editor-fold>                                 
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">                                                 
    
        public void commandAction(Command command, Displayable displayable) {                                               
            // write pre-action user code here
            if (displayable == smsComposer) {                                           
                if (command == SMSComposer.SEND_COMMAND) {                                         
                    // write pre-action user code here
                    switchDisplayable(null, getWaitScreen());                                           
                    // write post-action user code here
                } else if (command == exitCommand1) {                                          
                    // write pre-action user code here
                    exitMIDlet();                                           
                    // write post-action user code here
                }                                           
            } else if (displayable == splashScreen) {
                if (command == SplashScreen.DISMISS_COMMAND) {                                         
                    // write pre-action user code here
                    switchDisplayable(null, getSmsComposer());                                           
                    // write post-action user code here
                }                                           
            } else if (displayable == waitScreen) {
                if (command == WaitScreen.FAILURE_COMMAND) {                                         
                    // write pre-action user code here
                    switchDisplayable(getAlert1(), getSmsComposer());                                           
                    // write post-action user code here
                } else if (command == WaitScreen.SUCCESS_COMMAND) {                                          
                    // write pre-action user code here
                    switchDisplayable(getAlert(), getSmsComposer());                                            
                    // write post-action user code here
                }                                                   
            }                                                 
            // write post-action user code here
        }                                
        //</editor-fold>                              
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand ">                                   
    
        public Command getExitCommand() {
            if (exitCommand == null) {                                 
                // write pre-init user code here
                exitCommand = new Command("Exit", Command.EXIT, 0);                                   
                // write post-init user code here
            }                         
            return exitCommand;
        }
        //</editor-fold>                       
    
    
    
    
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand1 ">                                   
    
        public Command getExitCommand1() {
            if (exitCommand1 == null) {                                 
                // write pre-init user code here
                exitCommand1 = new Command("Exit", Command.EXIT, 0);                                   
                // write post-init user code here
            }                         
            return exitCommand1;
        }
        //</editor-fold>                       
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Getter: splashScreen ">                                   
    
        public SplashScreen getSplashScreen() {
            if (splashScreen == null) {                                 
                // write pre-init user code here
                splashScreen = new SplashScreen(getDisplay());                                    
                splashScreen.setTitle("splashScreen");
                splashScreen.setCommandListener(this);                                  
                // write post-init user code here
            }                         
            return splashScreen;
        }
        //</editor-fold>                       
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Getter: smsComposer ">                                   
    
        public SMSComposer getSmsComposer() {
            if (smsComposer == null) {                                 
                // write pre-init user code here
                smsComposer = new SMSComposer(getDisplay());                                    
                smsComposer.setTitle("smsComposer");
                smsComposer.addCommand(SMSComposer.SEND_COMMAND);
                smsComposer.addCommand(getExitCommand1());
                smsComposer.setCommandListener(this);
                smsComposer.setBGColor(-3355444);
                smsComposer.setFGColor(-16777216);
                smsComposer.setPhoneNumberLabel("Phone Number Label");
                smsComposer.setMessageLabel("Message Label");                                  
                // write post-init user code here
            }                         
            return smsComposer;
        }
        //</editor-fold>                       
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Getter: waitScreen ">                                   
    
        public WaitScreen getWaitScreen() {
            if (waitScreen == null) {                                 
                // write pre-init user code here
                waitScreen = new WaitScreen(getDisplay());                                    
                waitScreen.setTitle("waitScreen");
                waitScreen.setCommandListener(this);
                waitScreen.setTask(getTask());                                  
                // write post-init user code here
            }                         
            return waitScreen;
        }
        //</editor-fold>                       
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Getter: alert ">                                   
    
        public Alert getAlert() {
            if (alert == null) {                                 
                // write pre-init user code here
                alert = new Alert("alert");                                    
                alert.setTimeout(Alert.FOREVER);                                  
                // write post-init user code here
            }                         
            return alert;
        }
        //</editor-fold>                       
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Getter: alert1 ">                                   
    
        public Alert getAlert1() {
            if (alert1 == null) {                                 
                // write pre-init user code here
                alert1 = new Alert("alert1");                                    
                alert1.setTimeout(Alert.FOREVER);                                  
                // write post-init user code here
            }                         
            return alert1;
        }
        //</editor-fold>                       
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Getter: task ">                                   
    
        public SimpleCancellableTask getTask() {
            if (task == null) {                                 
                // write pre-init user code here
                task = new SimpleCancellableTask();                                   
                task.setExecutable(new org.netbeans.microedition.util.Executable() {
                    public void execute() throws Exception {                                 
                        // write task-execution user code here
                    }                                    
                });                                  
                // write post-init user code here
            }                         
            return task;
        }
        //</editor-fold>                       
    
        public Display getDisplay () {
            return Display.getDisplay(this);
        }
    
        public void exitMIDlet() {
            switchDisplayable (null, null);
            destroyApp(true);
            notifyDestroyed();
        }
    
        public void startApp() {
            if (midletPaused) {
                resumeMIDlet ();
            } else {
                initialize ();
                startMIDlet ();
            }
            midletPaused = false;
        }
    
           public void pauseApp() {
            midletPaused = true;
        }
    
        public void destroyApp(boolean unconditional) {
        }
    
    }
    Last edited by imu09; 04-29-2011 at 08:28 PM.

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default

    The closing code tag is [/code], Please edit your post and correct it.

    db

    edit And get rid of all the IDE-generated garbage.
    Last edited by DarrylBurke; 04-29-2011 at 08:09 PM. Reason: Glanced through the 'code'

  8. #8
    imu09 is offline Member
    Join Date
    Apr 2011
    Posts
    16
    Rep Power
    0

    Default

    It's done!

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default

    No, it isn't. There's still a huge number of commented lines that only serve to make the code less readable.

    0) What's the actual error message?
    1) What libraries and resources are added to the project?
    2) How did you build the jar?

    db

  10. #10
    imu09 is offline Member
    Join Date
    Apr 2011
    Posts
    16
    Rep Power
    0

    Default

    I don't understand. I used the netbeans visual builder thing, so I can make apps without much coding. Here's a screenshot:
    http://img39.imageshack.us/i/unledpicture.png/
    And netbeans automatically makes the code, and then I just used the 'clean and build' thing to compile it into a jar file, and the code that I gave you the code as I got it in netbeans. I don't know anything about libraries. If you're talking about the 'lib' folder that came with the jar file, it was empty.

  11. #11
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default

    You still haven't answered the first question. And no, I'm not referring to the lib folder under dist. I'm referring to Project -> Properties -> Libraries and Resources.

    Also, you still haven't removed the IDE generated clutter, which makes your code next to unreadable.

    db

  12. #12
    imu09 is offline Member
    Join Date
    Apr 2011
    Posts
    16
    Rep Power
    0

    Default

    What do you mean by IDE generated clutter? the
    Java Code:
     // write the ... here
    ? Or the
    Java Code:
     }
    ?
    also, the message is 'Execution failed with error code 1' when I try to run it in netbeans with an emulator, and it's 'java/lang/ClassNotFoundException' when I open it in my phone.
    Last edited by imu09; 04-30-2011 at 02:27 PM.

  13. #13
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default



    Here's your code without the clutter and with an empty method and default constructor removed for brevity.
    Java Code:
    import javax.microedition.midlet.*;
    package coolSMS;
    
    import javax.microedition.lcdui.*;
    import org.netbeans.microedition.lcdui.SplashScreen;
    import org.netbeans.microedition.lcdui.WaitScreen;
    import org.netbeans.microedition.lcdui.wma.SMSComposer;
    import org.netbeans.microedition.util.SimpleCancellableTask;
    
    public class coolSMS extends MIDlet implements CommandListener {
    
      private boolean midletPaused = false;
      private Command exitCommand;
      private Command exitCommand1;
      private SplashScreen splashScreen;
      private SMSComposer smsComposer;
      private WaitScreen waitScreen;
      private Alert alert;
      private Alert alert1;
      private SimpleCancellableTask task;
    
      public void startMIDlet() {
        switchDisplayable(null, getSplashScreen());
      }
    
      public void switchDisplayable(Alert alert, Displayable nextDisplayable) {
        Display display = getDisplay();
        if (alert == null) {
          display.setCurrent(nextDisplayable);
        } else {
          display.setCurrent(alert, nextDisplayable);
        }
      }
    
      public void commandAction(Command command, Displayable displayable) {
        if (displayable == smsComposer) {
          if (command == SMSComposer.SEND_COMMAND) {
            switchDisplayable(null, getWaitScreen());
          } else if (command == exitCommand1) {
            exitMIDlet();
          }
        } else if (displayable == splashScreen) {
          if (command == SplashScreen.DISMISS_COMMAND) {
            switchDisplayable(null, getSmsComposer());
          }
        } else if (displayable == waitScreen) {
          if (command == WaitScreen.FAILURE_COMMAND) {
            switchDisplayable(getAlert1(), getSmsComposer());
          } else if (command == WaitScreen.SUCCESS_COMMAND) {
            switchDisplayable(getAlert(), getSmsComposer());
          }
        }
      }
    
      public Command getExitCommand() {
        if (exitCommand == null) {
          exitCommand = new Command("Exit", Command.EXIT, 0);
        }
        return exitCommand;
      }
    
      public Command getExitCommand1() {
        if (exitCommand1 == null) {
          exitCommand1 = new Command("Exit", Command.EXIT, 0);
        }
        return exitCommand1;
      }
    
      public SplashScreen getSplashScreen() {
        if (splashScreen == null) {
          splashScreen = new SplashScreen(getDisplay());
          splashScreen.setTitle("splashScreen");
          splashScreen.setCommandListener(this);
        }
        return splashScreen;
      }
    
      public SMSComposer getSmsComposer() {
        if (smsComposer == null) {
          smsComposer = new SMSComposer(getDisplay());
          smsComposer.setTitle("smsComposer");
          smsComposer.addCommand(SMSComposer.SEND_COMMAND);
          smsComposer.addCommand(getExitCommand1());
          smsComposer.setCommandListener(this);
          smsComposer.setBGColor(-3355444);
          smsComposer.setFGColor(-16777216);
          smsComposer.setPhoneNumberLabel("Phone Number Label");
          smsComposer.setMessageLabel("Message Label");
        }
        return smsComposer;
      }
    
      public WaitScreen getWaitScreen() {
        if (waitScreen == null) {
          waitScreen = new WaitScreen(getDisplay());
          waitScreen.setTitle("waitScreen");
          waitScreen.setCommandListener(this);
          waitScreen.setTask(getTask());
        }
        return waitScreen;
      }
    
      public Alert getAlert() {
        if (alert == null) {
          alert = new Alert("alert");
          alert.setTimeout(Alert.FOREVER);
        }
        return alert;
      }
    
      public Alert getAlert1() {
        if (alert1 == null) {
          alert1 = new Alert("alert1");
          alert1.setTimeout(Alert.FOREVER);
        }
        return alert1;
      }
    
      public SimpleCancellableTask getTask() {
        if (task == null) {
          task = new SimpleCancellableTask();
          task.setExecutable(new org.netbeans.microedition.util.Executable() {
    
            public void execute() throws Exception {
            }
          });
        }
        return task;
      }
    
      public Display getDisplay() {
        return Display.getDisplay(this);
      }
    
      public void exitMIDlet() {
        switchDisplayable(null, null);
        destroyApp(true);
        notifyDestroyed();
      }
    
      public void startApp() {
        if (!midletPaused) {
          startMIDlet();
        }
        midletPaused = false;
      }
    
      public void pauseApp() {
        midletPaused = true;
      }
    
      public void destroyApp(boolean unconditional) {
      }
    }
    Now will you tell us what you have in the project's 'Libraries and Resources'?

    This is getting to be worse than pulling teeth.

    db
    Last edited by DarrylBurke; 04-30-2011 at 03:24 PM. Reason: Removed another empty method

  14. #14
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,519
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Darryl.Burke View Post
    The average fun day at the forums?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  15. #15
    imu09 is offline Member
    Join Date
    Apr 2011
    Posts
    16
    Rep Power
    0

    Default

    Gulp! I'm getting desperate and your getting mad. How am I supposed to make mobile apps if my first app turns out to be a flunk? Anyways, the resource and libs had this in in:
    Netbeans MIDP components
    Netbeans MIDP components WMA
    Plus, just to be sure, this is what you mean, right?
    ImageShack&#174; - Online Photo and Video Hosting

  16. #16
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default

    Now we're getting somewhere.

    Are the checkboxes in the 'package' column on the ''Libraries and Resources' tab (to the right of the Name column) checked or unchecked?

    db

  17. #17
    imu09 is offline Member
    Join Date
    Apr 2011
    Posts
    16
    Rep Power
    0

    Default

    Theyr'e checked. Didn't you see them in the screenshot that was in the link?

  18. #18
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default

    I don't click external links.


    Next step for you is to open the jar file and verify that the packages and classes have been included in the jar biold. The jar structure should be something like
    Java Code:
    coolSMS -+- coolSMS$1.class
             |
             +- coolSMS.class
    
    META-INF -+- MANIFEST.MF
    
    org -+- netbeans -+- microedition -+- lcdui -+- laf (contains 5 classes)
                                       |         |
                                       |         +- wma (contians 4 classes)
                                       |
                                       +- util (contains 3 classes)
    Can you confirm that?

    Note: open the jar file directly with a zip utility if you have one, or make a copy, rename the extension to .zip and open it like any other zip file.

    db
    Last edited by DarrylBurke; 04-30-2011 at 06:33 PM.

  19. #19
    imu09 is offline Member
    Join Date
    Apr 2011
    Posts
    16
    Rep Power
    0

    Default

    Confirmed. That's exactly what the java file looks like.

  20. #20
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default

    Quote Originally Posted by imu09 View Post
    Confirmed. That's exactly what the java file looks like.
    The java file?

    db

Page 1 of 2 12 LastLast

Similar Threads

  1. Lil prob
    By imu09 in forum CLDC and MIDP
    Replies: 8
    Last Post: 04-28-2011, 05:30 PM
  2. Vector Prob
    By wierdal in forum New To Java
    Replies: 4
    Last Post: 05-04-2009, 10:37 PM
  3. another compilation prob!!!
    By aiacos88 in forum JCreator
    Replies: 4
    Last Post: 01-27-2009, 03:16 AM
  4. for each prob
    By kusumathatavarthi in forum New To Java
    Replies: 7
    Last Post: 05-21-2008, 01:00 PM
  5. Prob with an exercise
    By jhetfield18 in forum New To Java
    Replies: 4
    Last Post: 02-15-2008, 06:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •