A DESCRIPTION OF THE PROBLEM :
The documentation for the MutlicastSocket says a DatagramPacket can be created like this:
DatagramPacket hi = new DatagramPacket(msgBytes, msgBytes.length,
group, 6789);
But the DatagramPacket doesn't have a constructor like this.
The code should be something like this:
DatagramPacket hi = new DatagramPacket(msgBytes, msgBytes.length,
group);
A second but not mandatory improvment would be to replace the variable port with 6789, like it is done in all other lines.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Go to:
https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/net/MulticastSocket.html#leaveGroup(java.net.SocketAddress,java.net.NetworkInterface)
You should see it right at the top of see page in the guide.