import java.net.InetAddress; import java.net.MulticastSocket; public class Main { public static void main(String[] argv) throws Exception { String groupName = "groupName"; int port = 1024; MulticastSocket msocket = new MulticastSocket(port); InetAddress group = InetAddress.getByName(groupName); msocket.joinGroup(group); } }