×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    34

    Exclamation Cannot create class in package system

    I write a Midlet (J2me) which uses bluetooth...
    The compiler accepts the file without errors but when I try to run a certain part of the code it says:
    ALERT:Cannot create class in system package
    Iam using midp2.0 and use the command line to execute...I defined the environment variables correctly and I DEFINED 2 CLASSES IN THE MIDLET..
    The Code is:
    Code:
    package doctor;
    import java.io.*;
    import java.lang.*;
    import java.util.*;
    import javax.bluetooth.*;
    import javax.microedition.io.*;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    
    public class Program extends MIDlet implements CommandListener
    {
    private Display display;
    private TextBox textBox1;
    private Command entryCommand;
    private Command exitCommand;
    public void startApp()
    {display=Display.getDisplay(this);
     entryCommand=new Command("OK", Command.SCREEN, 1);
     exitCommand=new Command("Quit", Command.SCREEN, 1);
     textBox1=new TextBox("How application works..", "This application helps to send an alert to the doctor to let him informed with his patient 's heart condition. It also allows the patient to monitor his heart illness and danger moments and how often does it happen.", 256, 0);
     textBox1.addCommand(entryCommand);
     textBox1.addCommand(exitCommand);
     textBox1.setCommandListener(this);
     display.setCurrent(textBox1);
    }
    public void pauseApp()
    {
    }
    public void destroyApp(boolean unconditional)
    {
    }
    public void commandAction(Command choice,Displayable displayable)
    {if(choice==exitCommand)
     {destroyApp(false);
      notifyDestroyed();
     }
     else
     { 
                try {
                    BLUE();
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
           }
    
           }
    public void BLUE() throws IOException
    { 
       UUID serviceUUID = new UUID(0x0003L);
       String serviceURL = "btspp://localhost:" + serviceUUID.toString() + ";name=com.example";
       StreamConnection con= null;
       StreamConnectionNotifier service= null;
       InputStream ip= null;
       OutputStream op=null;
        service=(StreamConnectionNotifier)Connector.open(serviceURL);
        con=service.acceptAndOpen();
        ip=con.openInputStream();
        op=con.openOutputStream();
          ReadThread rdthr=new ReadThread(ip,op);
          rdthr.start();
    }
     class ReadThread extends Thread implements Runnable
    {InputStream ip=null;OutputStream op=null;
     public ReadThread (InputStream inp,OutputStream onp){ip=inp;op=onp;}
     public void run()
     {
      try{char data;
          data=(char)ip.read();
          op.write(data);
         }
      catch(IOException e){}
     }
    }
    
    }
    If this is the wrong section please MODERATORS move the post to the correct one
    Thanks

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Cannot create class in package system

    Which SDK are you using? (WTK, Java ME SDK, Nokia, etc.)

    What command line are you using to run the app?

    What environment variables have you defined? (You shouldn't need to define any.)

    Graham.

  3. #3
    Registered User
    Join Date
    Apr 2010
    Posts
    34

    Re: Cannot create class in package system

    Thanks for your reply

    1-I used latest java development kit at SUN (JDK 6u20 windows i586.exe)
    2-At Command prompt (in windows visita) I write:midp -classpath C:\j2me\classes doctor.Program
    where doctor is the folder at which the class program is found...this class is generated from the previously posted code compilation
    3-modifying CLASSPATH ,PATH ,MIDP_HOME look at book Complete Reference J2ME Page 48 to understand what I mean
    Here is a link to the book:
    http://www.21gradi.it/Public/Java_J2...ll_Osborne.pdf

  4. #4
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Cannot create class in package system

    Which mobile SDK are you using?

    You should not need to change your classpath...

    This error is caused by having classes in your application in packages that conflict with the system classes (like java., javax., etc.). Assuming your classes are not in these packages, then for some reason the emulator is seeing it's own API library as part of your application (perhaps because it's in the classpath, rather than the boot-classpath).

    I suggest you undo all the changes you made to your environment variables, uninstall whatever mobile SDK you're using, and re-install it (follow the SDK's instructons, not the book). Don't change anything else. Then try running it, again following the SDK documentation.

    Graham.

  5. #5
    Registered User
    Join Date
    Apr 2010
    Posts
    34

    Re: Cannot create class in package system

    Which SDK are you suggesting??

  6. #6
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Cannot create class in package system

    Your mobile SDK. That's usually either the Wireless Toolkit or the Java ME SDK 3.0. Or it could be some manufacturer SDK. I have no idea which you're using.

    Graham.

  7. #7
    Registered User
    Join Date
    Apr 2010
    Posts
    34

    Re: Cannot create class in package system

    I will do what you said and I will get back to you in case of problems...

    Thanks for your help

    Johnny

  8. #8
    Registered User
    Join Date
    Apr 2010
    Posts
    34

    Re: Cannot create class in package system

    OK Iam now using Wireless toolkit as i faced some problems using SDK ME and the problem is that setting tab allows me to enter all data related to midlet and I still donot know how to add the written source code itself

  9. #9
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Cannot create class in package system

    The Wireless Toolkit is an SDK, it is not an IDE.

    Which SDK were you using before?

    What is the problem with the Java ME SDK?

    Graham.

  10. #10
    Registered User
    Join Date
    Apr 2010
    Posts
    34

    Re: Cannot create class in package system

    I wasnot using any SDK... just jdk and command line(I mean by command line the black screen which can be cmd.exe in some windows version) as that book said(book link posted before)
    When I said that I had problems with SDK I meantJava ME SDK not wireless toolkit..
    The problem after I installed wireless toolkit was that I donot know how to load my source program...
    Last edited by johnnydarten; 2010-05-03 at 17:20.

  11. #11
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Cannot create class in package system

    You must have something else installed. The JDK does not support MIDP development... you would not have been able to compile your MIDlet. How were you compiling your MIDlet before?

    Again, what problem did you have with the Java ME SDK?

    Graham.

  12. #12
    Registered User
    Join Date
    Apr 2010
    Posts
    34

    Re: Cannot create class in package system

    look at page 48 of book J2ME Complete reference...
    Link:http://www.21gradi.it/Public/Java_J2...ll_Osborne.pdf
    I did exactly what is written in this page to start working with this midlet

    About Java ME SDK I installed it then every time I have many exceptions(IOEXCEPTION)when I run the program..After running it I try to start a new project it starts to ask me for something missing on my computer so it cannot run and I couldnot know what he meant so I just used Wireless toolkit...

    I donot know what is the difference between library and resource files of the application It asked me in WTK for them..do u know??
    Thanks

  13. #13
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Cannot create class in package system

    I suggest you delete your copy of that book, and never look at it again. It's complete rubbish, and I'm not surprised you've had a confusing time if you've been following those instructions.

    However, it does say "You’ll also need the J2ME Wireless Toolkit to develop MIDlets for handheld devices", so presumably you did this.

    It says:

    Three software packages need to be downloaded from java.sun.com. These are the Java Development Kit (1.3 or greater) (java.sun.com/j2se/downloads.html), Connected Limited Device Configuration (CLDC) (java.sun.com/products/cldc/), and the Mobile Information Device Profile (MIDP) (java.sun.com/products/midp/). You’ll also need the J2ME Wireless Toolkit to develop MIDlets for handheld devices (java.sun.com/products/j2mewtoolkit/download.html).
    Please, uninstall everything you have installed. The WTK you've just installed, the Java ME SDK, the previous WTK, any MIDP and CLDC stuff, and the JDK. Get back to a point before you started.

    Then, let's start again.

    Install the JDK 6.0.

    Install the Java ME SDK 3.0.

    Next, build and run some of the sample applications that come with the Java ME SDK. There is no point trying your own code until you're confident that the SDK is installed and working correctly. If it doesn't work, post a question in the tools and SDKs discussion board, with a link to this thread.

    Next, try running the Bluetooth demo. Read the SDK's documentation for how to run this in the emulator environment. You need to see how Bluetooth simulation works. Note that you can only Bluetooth-connect two emulators. You cannot connect an application running in the emulator to a real Bluetooth device.

    Finally, try building and running your own code.

    Graham.

  14. #14
    Registered User
    Join Date
    Apr 2010
    Posts
    34

    Re: Cannot create class in package system

    I suggest you delete your copy of that book, and never look at it again. It's complete rubbish, and I'm not surprised you've had a confusing time if you've been following those instructions.
    I have been reading in this book since I started...It is really awful.

    Thanks Graham for all your help...I really appreciate it

    Johnny

  15. #15
    Registered User
    Join Date
    Apr 2010
    Posts
    34

    Re: Cannot create class in package system

    The completion of the thread is at :
    http://discussion.forum.nokia.com/fo...501#post732501

Similar Threads

  1. Replies: 7
    Last Post: 2008-05-02, 08:40
  2. Need one HTTP client example
    By vinayakak in forum Symbian Networking & Messaging (Closed)
    Replies: 15
    Last Post: 2008-01-06, 06:44
  3. send array[0] different class
    By gift_te in forum Symbian
    Replies: 0
    Last Post: 2007-03-28, 13:04
  4. Replies: 2
    Last Post: 2007-03-14, 17:15
  5. Create Application Package is permanently Disabled
    By Shazard in forum Mobile Java General
    Replies: 2
    Last Post: 2003-08-08, 20:46

Posting Permissions

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