Alternative to System.getProperty("microedition.hostname")

Hey is there any other alternative for 'System.getProperty("microedition.hostname")' to get the ip address of the device running the j2me midlet ??
When you run the midlet on the emulator, System.getProperty("microedition.hostname") returns the PC's Name, but on a Nokia series 40(3rd E) device, it returns null.
So is there an alternative to this to select the device's ip address ?

First this is a pretty specific question which applies to a specific device rather than to reflection/reference. You might want to look for a forum that addresses the specific device.
Second, you can print the system properties normally. Whether you can do that on the device depends on the device. If you succeed you might find an alternative.
Third normally one uses the java.net.IpAddress to get a device IP. Does that not work for that device?

Similar Messages

  • System.getProperty("pc.name") ???

    As the title of this post implies, I would like to get the PC name from within a client-side java app. Unfortunately "pc.name" is not a valid system property key. Nor are there any, as far as I can tell, that give me what I want.
    Can anybody tell me how a client-side app can get the name of the PC on which it is running?
    To be completely clear, I want the name that shows up when I click Start > Settings > Control Panel > System > Network Identification. (Yes, I'm running Win2K...)
    Thanks!
    Bill

    Hi,
    :. Try this one. Comments in Portuguese.
    class ... whatever you want, a library for instance.
      public static final String OS_WINDOWS        = "Windows";
      public static final String OS_LINUX          = "Linux";
      public static final int CMD_SUCCESS          = 0;
      // = = = = = = = = = = = = = = = = = = = = = = =
      // Carrega as variaveis de ambiente (#014)
      public static boolean loadEnvironmentVariables()
      { boolean bRet  = false;
        String cmd    = "";
        String opsys  = System.getProperty("os.name","");
        try
        { if (opsys.startsWith(OS_LINUX))   cmd = "sh -c set";
          if (opsys.startsWith(OS_WINDOWS)) cmd = "command.com /c set";
          if (!cmd.equals(""))
          { Process p = Runtime.getRuntime().exec(cmd);
            if (p.waitFor() == CMD_SUCCESS)
            { InputStream is = p.getInputStream();
              Properties pr  = new Properties(System.getProperties());
              pr.load(is);
              System.setProperties(pr);
              bRet = true;
        catch(Exception e) {}
        finally
          return bRet;
      // = = = = = = = = = = = = = = = = = = = = = = =
      // Hostname (#016)
      public static String getHostname()
      { String sRet  = "";
        String opsys = System.getProperty("os.name","");
        if (opsys.startsWith(OS_LINUX))
        { sRet = System.getProperty("HOSTNAME","");
        else if (opsys.startsWith(OS_WINDOWS))
        { sRet = System.getProperty("COMPUTERNAME","");
        return sRet;
      // = = = = = = = = = = = = = = = = = = = = = = =
      // Username (#017)
      public static String getUsername()
      { String sRet  = "";
        String opsys = System.getProperty("os.name","");
        if (opsys.startsWith(OS_LINUX))
        { sRet = System.getProperty("USER","");
        else if (opsys.startsWith(OS_WINDOWS))
        { sRet = System.getProperty("USERNAME","");
        return sRet;
    :. First, call loadEnvironmentVariables method then getUsername,  getHostname, etc. Hope it helps and it was what you meant.
    Regards.
    Roque.

  • System.getProperty( "com.nokia.mid.imei" ) return null ?!?!

    hello guys,
    i intend to get the IMEI No. i wrote the following code:
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    public class IMEIDemo extends MIDlet
         Display display;
         private Form mainForm;
         String imeiNokia = "";
         public void startApp()
              display = Display.getDisplay( this );
              mainForm = new Form( "IMEI Demo" );
              imeiNokia = System.getProperty( "com.nokia.mid.imei" );
              if( imeiNokia.compareTo( "" ) == 0 )
                   System.out.println( "NULL..." );
              else
                   mainForm.append( imeiNokia );
                   display.setCurrent( mainForm );
         public void pauseApp()
         public void destroyApp( boolean b )
              destroyApp( false );
              notifyDestroyed();
    } // IMEIDemoi am using WTK2.2, MIDP2, CLDC1.1
    when i run this code in emulator (WToolKit), i got the following Exception:
    startApp threw an Exception
    java.lang.NullPointerException
    java.lang.NullPointerException
         at IMEIDemo.startApp(+36)
         at javax.microedition.midlet.MIDletProxy.startApp(+7)
         at com.sun.midp.midlet.Scheduler.schedule(+270)
         at com.sun.midp.main.Main.runLocalClass(+28)
         at com.sun.midp.main.Main.main(+116)
    would u pls suggest me how can i overcome this problem or any effective openion?
    thanx in advance.
    take care all.
    bye.

    hi
    i tried this program using J2ME to retireve IMEI number
    * IMEINO.java
    * Created on February 19, 2007, 3:50 PM
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    * @author Administrator
    * @version
    public class IMEINO extends MIDlet implements CommandListener{
    public TextField t1,t2,t3;
    public Form form;
    public String s1,s2,s3,n=null;
    public Display disp;
    public Command ok,exit;
    public IMEINO()
    form = new Form("IMEI");
    t1 = new TextField("imei1","",50,TextField.ANY);
    t2 = new TextField("imei2","",50,TextField.ANY);
    t3 = new TextField("imei3","",50,TextField.ANY);
    ok = new Command("ok",Command.OK,1);
    exit = new Command("exit",Command.EXIT,2);
    public void startApp() {
    form.addCommand(ok);
    form.setCommandListener(this);
    form.addCommand(exit);
    form.setCommandListener(this);
    form.append(t1);
    form.append(t2);
    form.append(t3);
    Display disp = Display.getDisplay(this);
    try
    s1 = System.getProperty("com.nokia.mid.imei");
    s2 = System.getProperty("phone.imei");
    s3 = System.getProperty("com.nokia.IMEI");
    if(s1.compareTo("") == 0 || s2.compareTo("")==0 || s3.compareTo("")==0 )
    t1.setString(null);
    else
    t1.setString(s1);
    t2.setString(s2);
    t3.setString(s3);
    catch(Exception e)
    t1.setString("error"+ e.getMessage());
    t2.setString(s2);
    t3.setString(s3);
    disp.setCurrent(form);
    public void commandAction(Command c,Displayable d)
    if(c==ok)
    destroyApp(true);
    notifyDestroyed();
    if(c == exit)
    destroyApp(true);
    notifyDestroyed();
    public void pauseApp() {
    public void destroyApp(boolean unconditional) {
    i tried this program , when i run in the netbeans environment , it shows null (system.out.println(imei)),when i installed the jar file into nokia 3230 mobile,the textfield is null , it shows nothing,can anyone give me any suggestion , whether i have to change my phone settings
    Message was edited by:
    scorpianalways

  • Problem with System.getProperty( "com.stc.application.dataroot" ) in JCAPS6

    Hello everybody,
    I'm using JCAPS 6 but I have to follow a guideline of projects implemented with JCAPS 5.1.3.
    The project for example, has written for the logs-directory in method user initialize this code:
    // JCAPS uses JVM version 1.5
    logger.info( "--- BEGIN ------ JCAPS userInitialize" );
    String currRoot = System.getProperty( "com.stc.application.dataroot" );
    String log4j_props = currRoot + "/../../NameDirectory/" + collabContext.getProjectPath() + "/" +
    collabContext.getCollaborationName() + "_log4j.properties";
    With JCAPS 6 I don't know how to substitute "System.getProperty( "com.stc.application.dataroot" );" because with it don't function.
    Somebody can help me?
    Thanx!
    Fabrizio

    This is the correct code:
    // JCAPS uses JVM version 1.5
    logger.info( "--- BEGIN ------ JCAPS userInitialize" );
    String currRoot = System.getProperty( "com.stc.application.dataroot" );
    String log4j_props = currRoot + "/../../NoemaLife/" + collabContext.getProjectPath() + "/" + collabContext.getCollaborationName() + "_log4j.properties";
    but I have the same problem...

  • System.getProperty("user.name") not working without /etc/passwd, CentOS 4.3

    Dear all,
    I'm having trouble getting the system property user.name (which we need in our ant scripts) on our CentOS box. :(
    When running the program below thru
    java dumpproperties2
    it prints "user.name='?'" on our CentOS 4.3. On win32 it works. It turns out that if you add the account corresponding to the EUID to /etc/passwd it works correctly. However, we don't use passwd authentication but an enterprise wide LDAP-system. Our /etc/nsswitch.conf says:
    passwd: files ldap
    One work around is to replace the java executable with a script that does
    /path/to/jdk/bin/java -Duser.name=$USER -Duser.home=$HOME $@
    Used jdk is j2se 1.5.0_13 Linux 32-bit.
    Some questions for the experts:
    1) Is there any other way?
    2) Is it a known issue that Linux versions of the jdk just looks in /etc/passwd to map uid to user name (and home dir) instead of doing what the rest of the system, like whoami, does? I haven't found anything in either the readme or installation instructions, nor in the bug db.
    Br, Jesper Tr�g�rdh
    public class dumpproperties2 {
        public static void main(String[] args) {
         String s = System.getProperty("user.name");
         System.out.println("user.name='" + s + "'");
    }

    Does this work?
    //public final class System
    public static String getenv(String name)Then you can access the USER environment from inside Java.

  • System.getProperty("user.dir") returns "/home/user" on Linux

    Has anyone else had the error when launching a jar from Linux (just by clicking it), System.getProperty("user.dir") returns the "/home/user" (or "~") value instead of the folder that the jar is in? Essentially, it returns "user.home" instead of "user.dir".
    This does not happen when I start the application from command line.
    (I know its not swing, but I wasn't sure where to post it)
    Is this just a simple Linux setting that isn't enabled by default? Ubuntu already made the file association after using apt-get to install Java 6.
    Cheers.
    -FBL

    Because, semmingly, the command is being set off as
    java -jar relative/pat/to/file.jarwhen you double click it, rather than
    cd relative/path/to
    java -jar file.jarIf you don't like this, I would say to find a Linux, preferably Ubuntu, forum and ask there if it is possible to change that handling, and if not, request that a cahnge be made to the code to change that handling. But, in any case, I doubt you are going to get an answer here about it.

  • Can we write %System.getProperty("CONFIG_MODE");% this stmt in EL or jstl

    Hi everyone,
    Can we write below statement in EL or jstl instead of using Scriplet.
    <%System.getProperty("CONFIG_MODE");%>
    Thanks,
    Nihar.T

    getting a system property is too much on the business logic side. You could create a bean that returns the system property as a member, like:
    public class PropertyBean
    public String getConfigMode()
      return System.getProperty("CONFIG_MODE");
    }then simply use EL in your JSP(s) to get the value from that bean. Of course you could just make the getConfigMode() method part of an existing bean you are using.

  • Enums for System.getProperty(...) method in Java API?

    Just had a thought today as a result of a colleaugue mis-spelling "file.separator" in a System.getProperty() call:
    How about an enum for the above method (e.g. SystemProperty) that has all the known properties and the String method for any prop not included in the enum?
    Am I being too greedy or pedantic about type-safety?
    Appreciate your feedback.
    Cheers,
    Ali
    Edited by: user7627452 on 30-Apr-2012 19:09

    Yes. The whole idea is that anybody can add their own. As opposed to an API.

  • System.getProperty("user.region") in JDK version 1.3 vrs. 1.4

    Hi guys,
    I wonder why, when I set the following instruction to detect the regional settings, I got different results using 1.3.1 vrs. 1.4.1?
    String slRegion = System.getProperty("user.region");
    If I use 1.3.1 then I got the right result, but if I use 1.4.1 I got a null value.
    I need to use JDK 1.4.1, that's why I'm interested in getting the answer.
    TIA.

    As I want to know the 2 letters of the countries, such as:
    IN_USA = "US";
    ES_MEXICO = "MX";
    ES_ARGENTINA = "AR";
    ES_BOLIVIA = "BO";
    ES_CHILE = "CL";
    ES_COLOMBIA = "CO";
    ES_COSTARICA = "CR";
    ES_REPDOMINIC = "DO";
    ES_ECUADOR = "EC";
    ES_SALVADOR = "SV";
    What would it be the syntaxis (line code) to get this info?
    I appreciate your help

  • [svn:bz-trunk] 20505: Bug: Watson #2818669 - AbstractAmfInput uses System. getProperty in Constructor leading to AccessControlException when using in Applet

    Revision: 20505
    Revision: 20505
    Author:   [email protected]
    Date:     2011-03-01 07:31:55 -0800 (Tue, 01 Mar 2011)
    Log Message:
    Bug: Watson #2818669 - AbstractAmfInput uses System.getProperty in Constructor leading to AccessControlException when using in Applet
    QA: Yes
    Doc: No
    Checkintests: Didn't run - the change was to wrap the System.getProperty in a try/catch that would have caused the SecurityException, so no real functionality change that could affect the check-in tests.
    Modified Paths:
        blazeds/trunk/modules/core/src/flex/messaging/io/amf/AbstractAmfInput.java

  • Java 7 u45 System.getProperty returns null

    After upgrade to u45, our web launch application stopped working. it failed at System.getProperty("myproperty").
    "myproperty" is defined as a
    <resources>       
    <j2se version="1.6+" initial-heap-size="64m" max-heap-size="256m"/>
           <jar href="nms_wsclient.jar" download="eager" main="true"/>
           <jar href="commons-httpclient.jar" download="eager"/>      
          <jar href="commons-codec.jar" download="eager"/>       
          <jar href="commons-logging.jar" download="eager"/>       
          <jar href="log4j.jar" download="eager"/>       
          <property name="myproperty"   value="http://138.120.128.94:8085/"/>
        </resources>
    with older version java ,System.getProperty("myproperty") works fine to return the value, but with u45 it returned null.
    Does anyone have the same problem? any idea how to fix it or work around it?
    Thanks,
    Zhongyao

    So did you succeed with the jnlp template ?
    After frustrating hours of that information useless JNLPSigningException trial & error, It seems that as :
    1. You can't make the j2se version variable
    2. You can't have your own variable property/values
    I've opened a bug report...
    The documentation is atrocious, with a vague "we reserve the right to blacklist variable elements, but we will never say which ones".
    The JNLP example in the various example is a joke - Its a hello world jnlp, not a real world one.
    The JNLPSigningException must have been written my the same guys at Microsoft that did the "An Unknown Error As Occurred".
    I've had to clear the cache at every test, seems that the JNLP Template check didn't get the new updated JNLP from the web server.
    /rant over
    I think I'll try to bypass that JNLP property mess and get javaws to download my own "jnlp name".xml.config...

  • System name and hostname in Technical system

    while configuring Technical system in SLD of PI 7.0, it asks System name and hostname.
    can you differentiate them or what data we have feed them?

    Hi Gabriel,
      When defining the Technical system in the SLD you have to mention the name of the technical system which is to be given in the system name option and as the technical system is the physical system so you need to mention the host name which is to be provided in the hostname option. Generally we will give the domain name in the hostname parameter.
    Please refer the below link for more info:
    https://www.sdn.sap.com/irj/sdn/wiki --> working with SLD.
    Regards,
    Prasanthi.

  • Applet, System.getProperty question

    I am trying to develop a simple applet that would capture the NT user name with System.getProperty("user.name"). This will not work with servlet because it will only return the server user.name. With applets running on clients systems, I was hoping that this will work. My applet has only 1 button and 1 text field. It runs fine in a debug mode in Forte 2.0. It generates an error msg when I run in in Forte. It doesn't do anything if I add the class to a html file. Am I on the right track here or what do I need to do to get this to work?
    private void button1ActionPerformed(java.awt.event.ActionEvent evt) {
    String login = System.getProperty("user.name");
    textField1.setText(login);
    This works in a debug mode in Forte, but fails when I run it. This is the error message:
    Exception occurred during event dispatching:
    java.security.AccessControlException: access denied (java.util.PropertyPermission user.name read)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:272)
    at java.security.AccessController.checkPermission(AccessController.java:399)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
    at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1278)
    at java.lang.System.getProperty(System.java:560)
    at LoginApplet.button1ActionPerformed(LoginApplet.java:40)
    at LoginApplet.access$0(LoginApplet.java:39)
    at LoginApplet$1.actionPerformed(LoginApplet.java:20)
    at java.awt.Button.processActionEvent(Button.java:329)
    at java.awt.Button.processEvent(Button.java:302)
    at java.awt.Component.dispatchEventImpl(Component.java:2595)
    at java.awt.Component.dispatchEvent(Component.java:2499)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
    at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)

    Hi,
    As you can see you received a Security exception, for a good reason. If you could access a username and/or password then your computer could be compromised. Anyone could then write an unseen applet embedded in their web page that gathers username/password for any computer that requests the web page. The security manager on that specific PC (or web browser) would have to be modified specifically to allow this sort of access, which is not advised because then anyone else with this type of applet could get the same information that you are attempting to get (if you request a web page on another site with that applet requesting you system information).
    Hopefully this helps.

  • System.getproperty("Var Name") gives null in RedHatLinux5

    Please provide some solution for this strange problem. I am able to get the system property value from terminal but when I use System.getproperty() I am getting null.
    Ex:
    echo $client
    ans: /home/naveen/client/classes
    from java program
    System.getproperty("client"); it gives null

    use getenv(), instead of getProperty()

  • Getting cell id in java me using System.getProperty

    Hi all
    I wish to get the cell id of the cell (I know it had been asked for more than a million times) that my nokia phone is currently connected to with the api listed here
    [http://wiki.forum.nokia.com/index.php/CS000947_-_Getting_Cell_ID_in_Java_ME|http://wiki.forum.nokia.com/index.php/CS000947_-_Getting_Cell_ID_in_Java_ME]
    As stated,
    System.getProperty("com.nokia.mid.cellid") works on S60 3rd Ed
    System.getProperty("Cell-ID") works on S40 3rd Ed
    However, I am unable to do so on N82, anyone have any idea why is that so?
    Or is there any kind soul with N95 can tell me whether it works on N95?

    yes.. I saw that thread before I posted this.. but the piece of code mentioned in the thread does not make use of the api listed in the wiki right?
    In fact, I'm not very clear as to what that mentioned code is doing.
    Moreover, my point would be, how come the api is listed in the wiki in that case.. that is, if it does not work.. :/

Maybe you are looking for

  • How can I force a new window each time I click on Safari?

    I am trying to set up a Mac for my parents with the same functionality as their old Windows box. In windows each time you click the IE icon it opens a new window. In Safari each time you click on the safari icon it just opens the current window you h

  • Terminal command to find most recently opened files

    Hello, I have a terminal command (bash) that will find the last opened file (singular) from a given directory.  "$(ls -t | head -n1)" I want to be able to search for multiple "last opened" files, say 20; I also want to be able to search either all us

  • Quick Migrate from SQL Server error

    I am attempting to migrate my databases from SQL Server 2000 to Oracle 11g. I am attempting to use the quick migrate feature of Oracle SQL Developer and receiving an error, the same error for every database during the build stage. The error is as fol

  • Infoobject dataload using BI table as datasource

    I have created an infoobject A,whose A (text) is having a datasource which is created from a BI table. System had generated the required proposal while creating the transformation and then created the Data Transfer Process and loaded the data into th

  • Jpg files visible then stopped but works on Internet Explorer.

    The source code for the page has the jpg files but does not show but it works on Internet explorer. On Firefox, I can still use the zip file to get the jpg files but it is more convenient to see them to see which ones I want. It was working but then