Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

I've been finding that since I got my new MacBook Pro and installed Java 8 on it, all of the Java Applications that I've been running have been taking an extremely long time to start or to establish network connections. This didn't seem to affect Java Applications that didn't use the network however. Turns out that the problem is to do with the local machine's hostname resolution and is easily fixed.

First you need to find the hostname of your Mac. You do this from System Preferences. Click the Sharing icon in System Preferences.
javahosts_1.png


You will see a box that shows the Computer Name, under that will be the hostname ending in .local. That's what you will need, so take note of it. In my case it was Enzyme.local.
javahosts_2.png




The next step is to update your /etc/hosts file. This must be done as root, so at the Terminal, type in "sudo vi /etc/hosts". This will ask for your password...
javahosts_4.png


Add the hostname you noted from earlier at the end of lines that start with "127.0.0.1" and "::1". If you don't know how to use vi, look here. You can also use nano instead, just replace "vi" in the command above with "nano".

In the end this is what my /etc/hosts file looked like:
javahosts_3.png


After making this change, I noticed that SoapUI took 5 seconds to start, before it was taking 21 seconds. Also SQL Developer was now taking just 3 seconds to connect to a database, versus 21 seconds prior to this change.

-i

Hope you found this post useful...

...so please read on! I love writing articles that provide beneficial information, tips and examples to my readers. All information on my blog is provided free of charge and I encourage you to share it as you wish. There is a small favour I ask in return however - engage in comments below, provide feedback, and if you see mistakes let me know.

If you want to show additional support and help me pay for web hosting and domain name registration, donations, no matter how small, are always welcome!

Use of any information contained in this blog post/article is subject to this disclaimer.
comments powered by Disqus
Other posts you may like...