Intellij IDEA 测试scala程序的时候:Exception in thread "main" java.lang.NoClassDefFoundError: scala/Predef$

Exception in thread "main" java.lang.NoClassDefFoundError: scala/Predef$
        at HelloWorld$.main(HelloWorld.scala:4)
        at HelloWorld.main(HelloWorld.scala)
Caused by: java.lang.ClassNotFoundException: scala.Predef$
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 2 more

说明:本机是MAC,用的是Intellij编辑器,SCALA库是intellij自带的SCALA插件库,编写hello,world报错

Intellij IDEA 测试scala程序的时候:Exception in thread

原因:SDK没有找到SCALA的库(lib),导致编译报错

解决方法:在项目中的SDK中添加SCALA的库,MAC环境下intellij IDEA自带SCALA插件库目录在:

/Users/williamwang/.m2/repository/org/scala-lang/scala-library

点击项目右键-》open module setting -》Platform Setting -》SDKs --》classpath中添加

/Users/williamwang/.m2/repository/org/scala-lang/scala-library/2.11.8/scala-library-2.11.8.jar

如图所示:

Intellij IDEA 测试scala程序的时候:Exception in thread

你可能感兴趣的:(IDEA)