What do you mean by "through a phone line"?
Actually if you make a call to ISP and get access to Internet you can use any network IP you want. This is "through a phone line".
If you talk about direct connect between two modems then you should think about comm package to access com port. This is "through a phone line" as well...
i've been living with this issues and discuss in this forum for some dark time.
the best way I can do is using RAS on windows (or other similar service on other OS) . Simply you have to configure your dialed computer to be able to accept incoming connection, on windows you can do this on "New Connection Wizard" by choosing "set up an advanced connection" option.
after that, you can dial a number connected on dialed computer, if dialing success, than a TCP/IP connection will be established. Then you can build java application to send/retrieve file or etc using socket.
or you can consider JDialUp API for this problem (this API help you to dial using java)