scala 无法在 Centos Linux 机器上运行

发布于 2024-10-11 01:57:24 字数 697 浏览 0 评论 0原文

帮助。我开始学习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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

栖迟 2024-10-18 01:57:24

虽然我没有专门用 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 just scala

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.

深海夜未眠 2024-10-18 01:57:24

对我来说,这看起来就像你没有执行你所认为的那样。

调用 scala 时尝试使用完整路径。

To me this looks like you are not executing, what you think you are.

Try using the full path when calling scala.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文