public static final void sendWakeOnLanPacket(String macAddr){
  final String IP="255.255.255.255";
  final int port=7;
  try {
    final byte[] MACBYTE=new byte[6];
    final String[] hex=macAddr.split("(\\:|\\-)");
    for (int i=0; i < 6; i++) {
      MACBYTE[i]=(byte)Integer.parseInt(hex[i],16);
    }
    final byte[] bytes=new byte[6 + 16 * MACBYTE.length];
    for (int i=0; i < 6; i++) {
      bytes[i]=(byte)0xff;
    }
    for (int i=6; i < bytes.length; i+=MACBYTE.length) {
      System.arraycopy(MACBYTE,0,bytes,i,MACBYTE.length);
    }
    final InetAddress address=InetAddress.getByName(IP);
    final DatagramPacket packet=new DatagramPacket(bytes,bytes.length,address,port);
    final DatagramSocket socket=new DatagramSocket();
    socket.send(packet);
    socket.close();
    LOGGER.info("Sent WOL packet to " + macAddr);
  }
 catch (  final Exception e) {
    LOGGER.error("Error sending WOL packet to " + macAddr,e);
  }
}

public static final void sendWakeOnLanPacket ( String macAddr ) { final String IP = "255.255.255.255" ; final int port = 7 ; try { final byte [ ] MACBYTE = new byte [ 6 ] ; final String [ ] hex = macAddr . split ( "(\\:|\\-)" ) ; for ( int i = 0 ; i < 6 ; i ++ ) { MACBYTE [ i ] = ( byte ) Integer . parseInt ( hex [ i ] , 16 ) ; } final byte [ ] bytes = new byte [ 6 + 16 * MACBYTE . length ] ; for ( int i = 0 ; i < 6 ; i ++ ) { bytes [ i ] = ( byte ) 0xff ; } for ( int i = 6 ; i < bytes . length ; i += MACBYTE . length ) { System . arraycopy ( MACBYTE , 0 , bytes , i , MACBYTE . length ) ; } final InetAddress address = InetAddress . getByName ( IP ) ; final DatagramPacket packet = new DatagramPacket ( bytes , bytes . length , address , port ) ; final DatagramSocket socket = new DatagramSocket ( ) ; socket . send ( packet ) ; socket . close ( ) ; LOGGER . info ( "Sent WOL packet to " + macAddr ) ; } catch ( final Exception e ) { LOGGER . error ( "Error sending WOL packet to " + macAddr , e ) ; } }
sends a wake - on - lan packet for specified mac address across subnet
