• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

networking problem :-( ????

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code given below is working for windows but its giving problem in MAC OS
In window platform its revaling host address & name if u given address or name of particular comp in network but cudn't revaling the name or ip address of MAC OS on the network,while in MAC OS this code ain't workn at al

import java.net.InetAddress;
import java.net.UnknownHostException;

public class GetInetInfo{
public static void main(String[] args){
if (args.length != 1) {
System.err.println("Usage: GetInetInfo address");
// System.exit(1);
return;
}

InetAddress address = null;
try {
address = InetAddress.getByName(args[0]);
} catch(UnknownHostException e) {
e.printStackTrace();
// System.exit(2);
return;
}
System.out.println("Host name: " + address.getHostName());
System.out.println("Host address: " + address.getHostAddress());



// System.exit(0);
return;
}
} // GetInetInfo



the err i'm getn in MAC OS::

java.net.UnknownHostException: datacentre: datacentre
at java.net.InetAddress.getAllByName0(InetAddress.java:948)
at java.net.InetAddress.getAllByName0(InetAddress.java:918)
at java.net.InetAddress.getAllByName(InetAddress.java:912)
at java.net.InetAddress.getByName(InetAddress.java:832)
at GetInetInfo.main(GetInetInfo.java:12)
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


cudn't revaling the name or ip address of MAC OS on the network,while in MAC OS this code ain't workn at al


To be honest, it sounds like the Mac isn't on the network. Try using some command line tools to double-check if its visible before worrying about your Java code (e.g. in Windows ping, nslookup, net view etc.)
 
Slime does not pay. Always keep your tiny ad dry.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic