scala无法编译脚本文件的问题

软件和网站开发以及相关技术探讨
回复
firestone
帖子: 31
注册时间: 2008-07-21 10:02

scala无法编译脚本文件的问题

#1

帖子 firestone » 2009-08-12 12:11

scala hello.scala
初学scala,到http://www.scala-lang.org/downloads下安装了scala-2 ... 旦运行脚本文件就报错,不知道哪位高手指点一下。

我按照样本,建立了hello.scala文件:
println("Hello, world, from a script!")
然后运行:
$ scala hello.scala

接着出下面的信息
Exception in thread "main" java.lang.NoClassDefFoundError: scala/tools/nsc/MainGenericRunner
Caused by: java.lang.ClassNotFoundException: scala.tools.nsc.MainGenericRunner
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
Could not find the main class: scala.tools.nsc.MainGenericRunner. Program will exit.

特此请教,谢谢!!
头像
no2song
帖子: 32
注册时间: 2009-05-19 23:08
联系:

Re: scala无法编译脚本文件的问题

#2

帖子 no2song » 2009-08-13 16:54

你用的 gcj 还是 sun 的 jdk?
only the foolish believes suffering is just wages for being different
firestone
帖子: 31
注册时间: 2008-07-21 10:02

Re: scala无法编译脚本文件的问题

#3

帖子 firestone » 2009-08-13 16:59

我用的是jdk
头像
no2song
帖子: 32
注册时间: 2009-05-19 23:08
联系:

Re: scala无法编译脚本文件的问题

#4

帖子 no2song » 2009-08-13 19:38

下的 scala 是哪版?path 设置好了?
only the foolish believes suffering is just wages for being different
firestone
帖子: 31
注册时间: 2008-07-21 10:02

Re: scala无法编译脚本文件的问题

#5

帖子 firestone » 2009-08-14 9:08

在etc/profile设置java
JAVA_HOME="/usr/java/jdk1.6.0_16"
CLASSPATH="$JAVA_HOME/lib:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar"
PATH="$PATH:$JAVA_HOME/bin"

scala安装在$HOME/opt/scala,是最新的2.7.5-final
我在自己的~/.bash_profile里面设置
SCALA_HOME="$SCALA_HOME:$HOME/opt/scala"
PATH="$PATH:$HOME/bin:$SCALA_HOME/bin"

export PATH
export CLASSPATH=$SCALA_HOME/lib/scala-library.jar:$CLASSPATH

如果设置有什么问题,请告诉我,谢谢!!
头像
no2song
帖子: 32
注册时间: 2009-05-19 23:08
联系:

Re: scala无法编译脚本文件的问题

#6

帖子 no2song » 2009-08-14 11:55

先把 classpath 的设置注释掉看看
only the foolish believes suffering is just wages for being different
回复