scala 无法在 Centos Linux 机器上运行
帮助。我开始学习Scala。我的程序在 Windows PC 上运行良好,但每当我尝试在 Linux 机器 (ibmp2) 上运行程序时,输出只是打印两次的主机名。请参阅下面的示例。怎么了?
[sean@ibmp2 ~]$ cat hello.scala val oneTwo = List(1, 2) val threeFour = List(3, 4) val oneTwoThreeFour = oneTwo ::: threeFour println(""+ oneTwo +" and "+ threeFour +" were not mutated.") println("Thus, "+ oneTwoThreeFour +" is a new list.") [sean@ibmp2 ~]$ scala hello.scala ibmp2: ibmp2 [sean@ibmp2 ~]$ which scala /usr/local/scala-2.8.1.final/bin/scala [sean@ibmp2 ~]$ scala Welcome to Scala version 2.8.1.final (Java HotSpot(TM) Client VM, Java 1.6.0_17). Type in expressions to have them evaluated. Type :help for more information. scala> println("hello") hello scala>
Help. I am starting out learning Scala. My programs run fine on my Windows PC, but anytime I try to run a program on my Linux box (ibmp2), the output is just the hostname printed twice. See example below. What's wrong?
[sean@ibmp2 ~]$ cat hello.scala val oneTwo = List(1, 2) val threeFour = List(3, 4) val oneTwoThreeFour = oneTwo ::: threeFour println(""+ oneTwo +" and "+ threeFour +" were not mutated.") println("Thus, "+ oneTwoThreeFour +" is a new list.") [sean@ibmp2 ~]$ scala hello.scala ibmp2: ibmp2 [sean@ibmp2 ~]$ which scala /usr/local/scala-2.8.1.final/bin/scala [sean@ibmp2 ~]$ scala Welcome to Scala version 2.8.1.final (Java HotSpot(TM) Client VM, Java 1.6.0_17). Type in expressions to have them evaluated. Type :help for more information. scala> println("hello") hello scala>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然我没有专门用 Scala 遇到过这个问题,但我在 CentOS/Fedora 上运行与网络相关的 Java 程序时遇到了问题,其根本原因是
localhost
没有反向解决在 INetAddress.java 中的某处查找查询(或者其他东西,自从我研究它以来已经有一段时间了。)因此,有两个建议:1)确保 Scala 不会尝试在后台启动 fsc 并使用
scala -nocompdaemon
而不仅仅是scala
2) 编辑您的主机文件 (
sudoedit /etc/hosts
) 并确保 localhost 和您计算机的自定义名称都是其中指定。我只是猜测,但这些可能会解决问题。
While I haven't run into it with Scala specifically, I have encountered issues with running networking-related Java programs on CentOS/Fedora where the root cause turned out to be that
localhost
was not resolved in a reverse lookup query somewhere in INetAddress.java (or something, it's been a while since I looked into it.) So, two suggestions:1) Ensure that Scala is not trying to fire up fsc in the background and connect to it by using
scala -nocompdaemon
instead of justscala
2) Edit your hosts file (
sudoedit /etc/hosts
) and make sure localhost and your machine's custom name are both specified therein.I'm just guessing, but these might resolve the issue.
对我来说,这看起来就像你没有执行你所认为的那样。
调用 scala 时尝试使用完整路径。
To me this looks like you are not executing, what you think you are.
Try using the full path when calling scala.