Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: InetAddress

  1. #1
    Junior Member
    Join Date
    Dec 2011
    Location
    India
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default InetAddress

    // Demonstrate InetAddress.
    import java.net.*;
    public class InetAddressTest
    {
    public static void main(String args[]) throws UnknownHostException
    {
    InetAddress Address = InetAddress.getLocalHost();
    System.out.println(Address);
    InetAddress SW[] = InetAddress.getAllByName("www.nba.com");
    for(int i = 0; i<SW.length; i++)
    System.out.println(SW[i]);
    }
    }

    //I typed this program in eclipse on my win 7 pc and when i tried to run got error message(its alert box with "Java Virtual Machine Launcher"as title of alert box) : "could not find the main class: InetAddressTest. Program will exit "

    // please help me , what i have to do to run the program..


  2. #2
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: InetAddress

    Quote Originally Posted by lanpan View Post
    // Demonstrate InetAddress.
    import java.net.*;
    public class InetAddressTest
    {
    public static void main(String args[]) throws UnknownHostException
    {
    InetAddress Address = InetAddress.getLocalHost();
    System.out.println(Address);
    InetAddress SW[] = InetAddress.getAllByName("www.nba.com");
    for(int i = 0; i<SW.length; i++)
    System.out.println(SW[i]);
    }
    }

    //I typed this program in eclipse on my win 7 pc and when i tried to run got error message(its alert box with "Java Virtual Machine Launcher"as title of alert box) : "could not find the main class: InetAddressTest. Program will exit "

    // please help me , what i have to do to run the program..
    Set Class Path.

  3. #3
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: InetAddress

    Can't you see the difference now? Your classpath is set to E and your classes are actually located in F. Well, i will recommend you to go through Lesson: Common Problems (and Their Solutions) (The Java™ Tutorials > Getting Started)

Similar Threads

  1. [SOLVED] InetAddress worn't work :(
    By Budlee in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 27th, 2011, 10:10 AM