Broadcasting is defined as sending a packet to all network nodes on a subnet. An IP network subnet mask divides an IP address into two parts: the network identifier and the node identifier. A broadcast address is defined as an IP address where all bits of the node identifier are set.

So, sending a broadcast packet from a Java program (or from a program in any other language, for that matter) simply requires you to specify the broadcast address as the destination for the packet.