Suggestion about detecting Private Ip Address with an applet
===

I'm having some troubles to detect client's private ip that conect to a web application I built.
 Take a look at my tests results(In machines that runs windows):
1-In some machines(from different location ,countries..) the applet give me the correct ip but
2-In others I've obtained ip=127.0.0.1 :
         What have I tried to solve this?
              A- for example: I've stopped the avast program protection(web shield) and the              applet start to give me the correct private ip.
              B- In others machines I tried "point A" but It didn't work
              C- I also edit host file but I didn't work as well

What I need from you is to help me to understand what is happening? where to look in order to resolve this...
Please don't answer saying "Why do you need the private ip? It could change..." ... I know all the machines that are going to connect to my web application so I can configure them.

Part of the source code that my applet use:

    private String PrivateIP(boolean flag)
    {
        String s1 = "unknown";
        String s2 = getDocumentBase().getHost();
        int i = 80;
        if(getDocumentBase().getPort() != -1)
            i = getDocumentBase().getPort();
        try
        {
            String s = (new Socket(s2, i)).getLocalAddress().getHostAddress();
            if(!s.equals("255.255.255.255"))
                s1 = s;
        }
        catch(SecurityException _ex)
        {
            s1 = "FORBIDDEN";
        }
        catch(Exception _ex)
        {
            s1 = "ERROR";
        }
        if(flag)
            try
            {
                s1 = (new Socket(s2, i)).getLocalAddress().getHostName();
            }
            catch(Exception _ex)
            {
                Stat = "Cannot Lookup this IP";
            }
        return s1;
    }



I'll let you more information:
 I've traid this http://www.auditmypc.com/digital-footprint.asp in order to obtain the ip from probably other method but the same result, I've also run http://www.auditmypc.com/firewall-test.asp and obtained in the machines that I couldn't obtained the correct ip a message like "Congratulations you don't have any port to be open" xD...

Thanks in advance!