[root@bogon Desktop]# scala /usr/local/scala-2.10.5/hello.scala
java.net.UnknownHostException: bogon: bogon: Name or service not known
at java.net.InetAddress.getLocalHost(InetAddress.java:1473)
at scala.tools.nsc.io.Socket$.localhost(Socket.scala:38)
at scala.tools.nsc.CompileSocket.getsock$1(CompileSocket.scala:169)
at scala.tools.nsc.CompileSocket.getOrCreateSocket(CompileSocket.scala:184)
at scala.tools.nsc.ScriptRunner.compileWithDaemon(ScriptRunner.scala:80)
at scala.tools.nsc.ScriptRunner.scala$tools$nsc$ScriptRunner$$compile$1(ScriptRunner.scala:123)
at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1.apply$mcZ$sp(ScriptRunner.scala:157)
at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1.apply(ScriptRunner.scala:131)
at scala.tools.nsc.ScriptRunner$$anonfun$withCompiledScript$1.apply(ScriptRunner.scala:131)
at scala.tools.nsc.util.package$.trackingThreads(package.scala:51)
at scala.tools.nsc.util.package$.waitingForThreads(package.scala:35)
at scala.tools.nsc.ScriptRunner.withCompiledScript(ScriptRunner.scala:130)
at scala.tools.nsc.ScriptRunner.runScript(ScriptRunner.scala:188)
at scala.tools.nsc.ScriptRunner.runScriptAndCatch(ScriptRunner.scala:201)
at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:76)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:96)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:105)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
Caused by: java.net.UnknownHostException: bogon: Name or service not known
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293)
at java.net.InetAddress.getLocalHost(InetAddress.java:1469)
... 17 more
java
樓主在執行一個Scala腳本小例子的時候出現瞭如上問題,基於樓主Linux是個菜鳥,因此一陣度娘仍然無果。vim
後發現是因爲系統連不上bogon這個主機名,致使scala腳本編譯失敗app
因此相似狀況可按以下步驟操做:spa
1.打開系統hosts文件,vim /etc/hosts.net
2.添加一條主機名和IP地址的映射,如127.0.0.1 bogonscala
這樣便解決了以前編譯失敗的問題ip