According to
this link, Java does not support raw sockets, so I don't think it's possible with Java. See man 7 raw for more info about raw sockets -- I've never had the change to use them, personally, so I can't say much more.
Edited to add: of course, this doesn't mean you can't do IP network programming with java, just that you don't get low level control over the IP header (it is generated transparently for you by the OS).