我正在尝试让Scala在IntelliJ 10.5.1中正常工作。我从“可用插件”设置安装了插件,然后尝试启动一个新的Java项目,在可用技术下选择“scala”。但是当我尝试运行它时,Scala说我没有在scala方面定义一个scala编译器。所以我去了那里,但我没有看到任何设置编译器的方法。另外,我项目中的.iml文件如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="scala" name="Scala">
<configuration>
<option name="compilerLibraryLevel" value="Global" />
<option name="pluginPaths">
<array>
<option value="$USER_HOME$/SDKs/scala/src/scala-compiler-src.jar" />
</array>
</option>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="scala " level="application" />
</component>
</module>
请注意,它似乎确实指向了正确的jar编译器目标。
我需要做什么?
编辑 -
编译器现在正在工作,但是当我运行时,我收到此错误:
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -Didea.launcher.port=7540 -Didea.launcher.bin.path=/Applications/IntelliJ IDEA 10 CE.app/bin -Dfile.encoding=UTF-8 -classpath /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/deploy.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/dt.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/javaws.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/jce.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/jconsole.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/management-agent.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/plugin.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/sa-jdi.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Classes/alt-rt.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Classes/alt-string.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Classes/charsets.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Classes/classes.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Classes/jsse.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Classes/ui.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/apple_provider.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/dnsns.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/localedata.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/sunjce_provider.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/sunpkcs11.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home:/Users/me/Projects/Scala/testing/out/test/testing:/Users/me/Projects/Scala/testing/out/production/testing:/Users/me/SDKs/scala/lib/scala-library.jar:/Users/me/SDKs/scala/lib/scala-swing.jar:/Users/me/SDKs/scala/lib/scala-dbc.jar:/Applications/IntelliJ IDEA 10 CE.app/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain hello_world
Exception in thread "main" java.lang.ClassNotFoundException: hello_world
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:113)
Process finished with exit code 1
答案 0 :(得分:6)
转到项目设置(可以通过 Ctrl + Alt + Shift + S 调用)并在库列表中选择 scala-compiler ,就像这样:
现在FacetManager
组件如下所示:
<component name="FacetManager">
<facet type="scala" name="Scala">
<configuration>
<option name="compilerLibraryLevel" value="Global" />
<option name="compilerLibraryName" value="scala-compiler-2.9.0.1" />
</configuration>
</facet>
</component>
答案 1 :(得分:4)
请参阅Project Configuration Guide。
如果使用SBT构建,我建议使用sbt-idea生成您的IDEA项目,并idea-sbt-plugin将IDEA中的项目编译委托给SBT。
答案 2 :(得分:2)
我想你需要将scala编译器库添加到全局库中。在模块设置中 - &gt;全球图书馆 - &gt;附加jar目录并选择scala安装目录下的lib文件夹,然后按om-nom-nom建议,以确保选择编译器。