Java help

Discussion in 'Java' started by ebymohan, Sep 22, 2010.

  1. ebymohan

    ebymohan New Member

    Joined:
    Sep 21, 2010
    Messages:
    3
    Likes Received:
    1
    Trophy Points:
    0
    i hav been programing java for a couple of months and now i need som help


    below applet program yeilds 2 different results when executed in net beans and when embeded in a html page
    when executed in net beans it shows the correct result (the correct IP addres of the system)
    when embeded in html it shows a different result(som other address and not the actual IP address)
    can u tel me why
    i want to get the correct IP adress from the HTML(to continue with my work)

    this is the code


    Code:
    import java.awt.*;
    import java.net.*;
    import javax.swing.*;
    
    public class NewEmpty extends JApplet {
        
        public void start() {
        try {
        InetAddress thisIp =InetAddress.getLocalHost();
        JOptionPane.showMessageDialog(null, "1The IP ADDRESS is " + thisIp, "IP ADDRESS",JOptionPane.PLAIN_MESSAGE );
        JOptionPane.showMessageDialog(null, "2The IP ADDRESS is " + thisIp.getHostAddress(), "IP ADDRESS",JOptionPane.PLAIN_MESSAGE );
        }
        catch(Exception e) {
        e.printStackTrace();
        }
        }
        public void paint(Graphics g) {
            g.setColor(Color.BLUE);
            g.fillRect(20, 20, 50, 30);
            g.setColor(Color.RED);
            g.fillRect(50, 30, 50, 30);
            g.drawString( " IP ADDRESS GETTER" , 70 , 30 );
        }
    }
     
    Last edited by a moderator: Sep 22, 2010
  2. ebymohan

    ebymohan New Member

    Joined:
    Sep 21, 2010
    Messages:
    3
    Likes Received:
    1
    Trophy Points:
    0
    plz som body help
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice