Search code examples
javajava-mej2mepolish

java.lang.nosuchfielderror in j2me app


Hey Hi Friends I am created one j2me app. it runs perfectly in Emulator but in Mobile it showing error like java.lang.nosuchfielderror:No such field HEADERS.[[Ljava/lang/String;. Why this happening with mobile, it runs good in emulator...... Please help me to remove this error......

public String connectPhoneName() throws Exception{
    String url = "http://122.170.122.186/Magic/getPhonetype.jsp";
    String phoneType;
        if ((conn = connectHttp.connect(url, HEADERS)) != null) {
            if ((in = connectHttp.getDataInputStream(conn)) != null) {
                byte[] data = connectHttp.readDATA(in, 100);
                phoneType = new String(data);
                System.out.println("DATA : " + phoneType);
            } else {
                throw new Exception("ERROR WHILE OPENING INPUTSTREAM");
            }
        } else {
            throw new Exception("COULD NOT ESTABLISH CONNECTION TO THE SERVER");
        }
    return phoneType;

}

In this code i have used HEADERS.


Solution

  • It looks like your app is using some (I guess) or static final or final field of some library class that does not exist in the profile of Java ME your mobile device implements.

    But I can't figure out where that field comes from. Perhaps you should search your codebase for use of "HEADER" as an identifier ...


    If the HEADER field is properly declared in your codebase (your MagiDEF interface) and the code you showed is using the HEADER from that interface, then you must have something wrong with your build or deployment process. Specifically, you are not deploying the version of MagiDEF that your code (above) has been compiled against. Maybe you've got an old version of something in some JAR file?

    Basically, the error indicates that you have a binary incompatibility between some of the classes / interfaces that make up your app.