×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    21

    java.lang.SecurityException problem in mobile jar creation

    Hello, I developed a mobile app in j2me, it's running good in emulator but when i creating jar of that project it giving the Exception of java.lang.SecurityException.
    so help me to sort out this exception, please help me as soon as posible

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

    Re: java.lang.SecurityException problem in mobile jar creation

    When you create the JAR??

    Or when you run it on a device? (What device?)

  3. #3
    Registered User
    Join Date
    Mar 2013
    Posts
    21

    Re: java.lang.SecurityException problem in mobile jar creation

    Quote Originally Posted by lbstracker View Post
    Hello, I developed a mobile app in j2me, it's running good in emulator but when i creating jar of that project it giving the Exception of java.lang.SecurityException.
    so help me to sort out this exception, please help me as soon as posible
    Quote Originally Posted by grahamhughes View Post
    When you create the JAR??

    Or when you run it on a device? (What device?)
    i am checking the jar on nokia N97mini

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

    Re: java.lang.SecurityException problem in mobile jar creation

    OK.

    Can you post the contents of your JAD (if you have one) and MANIFEST files, please?

    Do you have any classes in the JAR in packages starting with "java.", "javax." or "com.nokia."?

    Does the exception appear as soon as you start the app, or when you do a specific thing?

  5. #5
    Registered User
    Join Date
    Mar 2013
    Posts
    21

    Re: java.lang.SecurityException problem in mobile jar creation

    error is occuring as soon as start app

    my main class file:

    import java.util.Hashtable;

    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    public class Tracker extends MIDlet implements CommandListener, ItemStateListener
    {
    Display display;
    Form form;
    private Image image = null;
    // private Command regCmd;
    private Command logCmd;
    private Command exitCmd;
    public LoginForm loginform;
    public Registration registration;
    GoogleMaps googlemap;
    mapCanvas mapcanvas;
    NetWorker networker;
    String website;
    public int res;
    protected Hashtable mHashtable;
    Thread locationThread1;
    private Displayable previousDisplayable;
    private ImageItem imageItem;
    public Tracker()
    {
    form = new Form("GPSTracker2.0");
    display = Display.getDisplay(this);
    exitCmd = new Command("Exit", Command.EXIT, 1);
    // regCmd = new Command("New Registration",Command.SCREEN, 2);
    logCmd = new Command("Login", Command.SCREEN, 3);
    mHashtable=new Hashtable();
    mHashtable.put("mobile", "");
    mHashtable.put("pass", "");
    mHashtable.put("min","");
    form.addCommand(exitCmd);
    //form.addCommand(regCmd);
    form.addCommand(logCmd);
    googlemap=new GoogleMaps();

    mapcanvas = new mapCanvas(this,"");
    form.setCommandListener(this);
    loginform = new LoginForm(this,googlemap,mapcanvas);
    registration=new Registration(this,loginform);
    try
    {
    image = Image.createImage("/abc.png");
    imageItem = new ImageItem(null, image,ImageItem.LAYOUT_NEWLINE_BEFORE |ImageItem.LAYOUT_LEFT |ImageItem.LAYOUT_NEWLINE_AFTER, "GPS Logo");
    form.append(imageItem);
    }
    catch (java.io.IOException error)
    {
    Alert alert = new Alert("Error", "Cannot load Image",null, null);
    alert.setTimeout(Alert.FOREVER);
    alert.setType(AlertType.ERROR);
    display.setCurrent(alert);
    }
    }
    public void sendloc(double lat,double lon)
    {
    loginform.sendloc(lat,lon);
    }
    public void toBack()
    {
    previousDisplayable = display.getCurrent();
    display.setCurrent(null);
    }
    public void toFront()
    {
    display.setCurrent(previousDisplayable);
    }
    public void log(String text)
    {
    StringItem si = new StringItem(null, text);
    si.setLayout(Item.LAYOUT_NEWLINE_AFTER);
    form.append(si);
    }
    public void startApp()
    {
    String mob=(String)mHashtable.get("min");
    if(mob.equals("true"))
    {
    mHashtable.put("min","false");
    toFront();
    }
    else
    {
    if(!mob.equals(""))
    {
    loginform.gps=new Gps(this,120,googlemap,mapcanvas);
    loginform.gps.startGPSloc();
    display.setCurrent(form);
    }
    else
    {
    registration.loadRegScreen();
    }
    }
    }
    public void itemStateChanged(Item item) {}
    public void pauseApp() {}
    public void displayMap()
    {
    display.setCurrent(mapcanvas);
    }
    public void destroyApp(boolean unconditional) {}

    protected void shutDownApp()
    {
    destroyApp(true);
    notifyDestroyed();
    }
    public void back1()
    {
    loginform.back();
    }
    public void back()
    {
    loginform.back();
    display.setCurrent(loginform.loginScreen);
    }
    public void sendDetails(String memName,String memMobile)
    {
    networker=loginform.networker;
    loginform.sendDetails(memName,memMobile);
    }

    public void commandAction(Command cmd, Displayable screen)
    {
    if (cmd == exitCmd)
    {
    shutDownApp();
    }
    else if (cmd == logCmd)
    {
    loginform.loadLoginScreen();
    }
    }
    }



    MANIFEST files:

    MIDlet-1: LBSTrackerChild, LBSTrackerChild.png, TrackerApp
    MIDlet-Name: LBSTrackerChild
    MIDlet-Vendor: KJCOEMR
    MIDlet-Version: 1.0
    MicroEdition-Configuration: CLDC-1.1
    MicroEdition-Profile: MIDP-2.1


    JAD file:

    MIDlet-1: LBSTrackerChild, LBSTrackerChild.png, TrackerApp
    MIDlet-Jar-Size: 48956
    MIDlet-Jar-URL: LBSTrackerChild.jar
    MIDlet-Name: LBSTrackerChild
    MIDlet-Vendor: KJCOEMR
    MIDlet-Version: 1.0
    MicroEdition-Configuration: CLDC-1.1
    MicroEdition-Profile: MIDP-2.1
    Last edited by lbstracker; 2013-03-21 at 09:34.

  6. #6
    Registered User
    Join Date
    Mar 2013
    Posts
    21

    Re: java.lang.SecurityException problem in mobile jar creation

    reply soon sir

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

    Re: java.lang.SecurityException problem in mobile jar creation

    The class you've given is called Tracker, but the manifest specifies TrackerApp as the MIDlet class. Why the mismatch?

  8. #8
    Registered User
    Join Date
    Mar 2013
    Posts
    21

    Re: java.lang.SecurityException problem in mobile jar creation

    sorry i posted my second app's manifest but my main class name is Tracker

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

    Re: java.lang.SecurityException problem in mobile jar creation

    I suggest you take all the code out of the constructor. You're constructing a number of objects here, so I have no idea what other code is being executed. Create objects when you need them, not all in advance.

    Also, strip startApp() down to the minimum. It needs only something like:

    Code:
    protected void startApp() {
        if (display == null) {
            display = Display.getDisplay(this);
            Displayable first = new WhateverYourFirstDisplayableIs();
            display.setCurrent(first);
        }
    }
    Reasons for stripping down these two methods:

    1. They run on the event thread - you should run as little code as possible on the event thread or your app will be unresponsive
    2. They run at start-up, so make your app take longer to start
    3. You will see the error later on rather than at start-up, giving you more idea of which bit of code is failing

    Some things you are not allowed to do (and can cause SecurityExceptions):

    1. Having classes in packages like java. or javax.
    2. Creating an instance of a class that extends MIDlet
    3. Opening a socket connection to ports 80, 8080 or 443
    4. Call System.exit() or Runtime.exit()

Similar Threads

  1. About : java.lang.error/Java.lang.SecurityException:Cannot use exit(), use midlet. ..
    By sisu.hang in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2010-08-11, 05:48
  2. Getting java.lang.SecurityException
    By nagesh.chetana in forum Mobile Java General
    Replies: 8
    Last Post: 2009-11-20, 15:53
  3. java.lang.SecurityException:
    By vivartpandey in forum Mobile Java General
    Replies: 2
    Last Post: 2008-07-17, 07:28
  4. java.lang.SecurityException
    By maneeshv6 in forum Mobile Java General
    Replies: 9
    Last Post: 2008-03-25, 20:23

Posting Permissions

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