Fixing java.net Local host name unknown error on Mac OS X

8 篇文章 0 订阅
2 篇文章 0 订阅

As some of you might know, I am a big fan of modular software (functional modules). So I love OSGiSnofyre is built on OSGi and Spring DM. Anyways, since I am in the process of rewriting Snofyre, I decided to rebase the previous OSGi code to a new OSGi framework. When doing this, I got a bizzare error at launch:

Error: Exception thrown by the agent : java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException: MB: MB: nodename nor servname provided, or not known

For someone who’s lived in the Java world for a while, this is something I found rather strange. I did all the sanity checks on my /etc/hosts file to ensure proper entries were present but still had no luck! I even tried reseting theComputer Name from System Preferences, still no joy! And then it struck me, that Mac OS X might have got itself in a twist and I had to set the ‘HostName’ manually. Doing that using Terminal is real easy using scutil. Here is how:

scutil –set HostName “localhost”

See screenshot below, where my previous HostName was set to ‘MB‘. I changed it to ‘localhost‘ using the above command. You can use scutil –get HostName to get the current hostname.

Change Hostname using scutil

You can read more about scutil here. Remember, you need to change the hostname to something that exists in your /etc/hosts file, otherwise you might still keep getting the UnknownHostException!

  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值