IDEA中运行scala报错:Exception in thread "main" java.lang.NoClassDefFoundError: scala/tools/nsc/interprete

一.问题

IDEA中运行scala报错:Exception in thread “main” java.lang.NoClassDefFoundError: scala/tools/nsc/interpreter/ILoop
在这里插入图片描述

class Test {
  def main(args: Array[String]): Unit = {
    print("hello world")
  }
}

二.解决

scala中类文件为object,所以应修改class为object,同时如果是class,点击右键会出现Run scala console。
同时需要注意,初始创建文件,默认是class选项,要修改为object选项。
在这里插入图片描述

发布了76 篇原创文章 · 获赞 44 · 访问量 20万+

猜你喜欢

转载自blog.csdn.net/qq_38278799/article/details/104390494
今日推荐