I want to create program that would check if the mobile phone is registered by using IMEI in a mobile phone?
How to get the IMEI number using J2me.
Could someone show me the right code in doing this..thnks in advance...

Dani AI

Generated

Short answer: MIDP/J2ME does not define a standard API to read the handset IMEI. Many phones do expose it through vendor-specific system properties, so the usual practical approach is: detect the phone platform, probe a short list of known property names, validate the result, and fall back to a generated install ID if IMEI is not available. was right to point toward vendor guides; the code below gives an implementation-ready pattern and a safer alternative.

Example J2ME pattern (probe vendor properties, validate digits):

private String getImei() {
    String[] keys = {
        "com.nokia.imei",
        "com.nokia.mid.imei",
        "com.sonyericsson.imei",
        "com.samsung.imei",
        "IMEI",
        "phone.imei"
    };
    for (int i = 0; i < keys.length; i++) {
        String val = System.getProperty(keys[i]);
        if (val != null && isDigits(val) && val.length() == 15) {
            return val;
        }
    }
    return null;
}

private boolean isDigits(String s) {
    if (s == null || s.length() == 0) return false;
    for (int i = 0; i < s.length(); i++) {
        char c = s.charAt(i);
        if (c < '0' || c > '9') return false;
    }
    return true;
}

Notes and troubleshooting

  • Some vendors only return IMEI to signed MIDlets or block access entirely; signing and vendor-certificates may be required. If System.getProperty keeps returning null, check the phone docs and signing requirements for that model.
  • Do not rely on IMEI as the only installation identifier: it can be unavailable, and privacy/legal rules may restrict its use. A robust approach is to generate a unique ID on first run, store it in RMS, and use that for registration.
  • If the target is Android (rather than a J2ME phone), use the Android Telephony APIs instead; runtime permissions and platform restrictions apply (see TelephonyManager.getImei and Android 10+ privacy changes: [TelephonyManager.getImei](https://developer.android.com/reference/android/telephony/TelephonyManager#getImei()) and Android 10 privacy changes).

Quick google search for "jme get imei" and you would have found with references for nokia, sony ericsson, motorola, samsung and siemens

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.