In order to do that, your Bluetooth stack has to support TCP/IP networking, and TCP/IP over Bluetooth has to be switch on and configured.
The details on how to do that will vary depending on the device you're using. It's done using the device OS control functions, not in
Java. And not all devices can do it.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.