the way how we get Ip address using java code is clear and many questions about this subject were answered.
but assuming that you have Vmware or VirtualBox on your machine,so you will have extra virtual network cards each one have its own Ip Address.
when executing a little program the result was like 192.168.x.x which belongs to one of my virtual network adapters. but using "What Is My IP" the result was like 197.x.x.x
so how can i get the ip adress of the connected interface ?