Import a Play Framework project to IntelliJ 14.1.5 Error - scala

Problem:
IntelliJ is not letting me import a play framework project. It just displays errors when I try to open project using SBT.
Its really simple what I want to do, but I haven't used any of these tools and I'm a bit lost at how to fix this.
I just want to create a Play framework project, and edit it in IntelliJ as shown on multiple tutorials on youtube.
Below I have provided some info about how I have tried to make it work to "help you help me".
I really hope there is some easy solution that I fail to see!
Background info:
I have downloaded and installed IntelliJ 14.1.5 Community Edition and the latest avtivator from Play Framework - Activator 1.3.6 and Play 2.4.3
Note: I also downloaded the latest java jdk, 1.8.0_65 and added both java and activator to path - I'm using Windows 8. I have also downloaded the latest plugin of Scala inside IntelliJ
Then I opened cmd and typed "activator ui" and opened browser at localhost:8888 as instructed in tutorials. I managed to create a "play-java-intro" project. So far, so good.
After this I have tried a few different approaches.
NOTE: I have clicked "Invalidate cache / restart" each time I try something new
First try
I tried to Open project after I had created the project through activator. I selected root directory of the project and selected SDK jdk 1.7 (have tried with 1.8 aswell).
I got the error
Error while importing SBT project: ... at
sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:70) at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:65) at sbt.Using.apply(Using.scala:24) at sbt.MainLoop$.runWithNewLog(MainLoop.scala:65) at sbt.MainLoop$.runAndClearLast(MainLoop.scala:48) at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:32) at sbt.MainLoop$.runLogged(MainLoop.scala:24) at sbt.StandardMain$.runManaged(Main.scala:53) at sbt.xMain.run(Main.scala:28) at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109) at xsbt.boot.Launch$.withContextLoader(Launch.scala:129) at xsbt.boot.Launch$.run(Launch.scala:109) at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:36) at xsbt.boot.Launch$.launch(Launch.scala:117) at xsbt.boot.Launch$.apply(Launch.scala:19) at xsbt.boot.Boot$.runImpl(Boot.scala:44) at xsbt.boot.Boot$.main(Boot.scala:20) at xsbt.boot.Boot.main(Boot.scala) [error] java.lang.UnsupportedClassVersionError: com/typesafe/config/ConfigException : Unsupported major.minor version 52.0 [error] Use 'last' for the full log.
Inside the log file:
[info] Loading project definition from C:\play-java-intro\project
[info] Set current project to play-java-intro (in build file:/C:/play-java-intro/)
java.lang.UnsupportedClassVersionError: com/typesafe/config/ConfigException : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at com.typesafe.sbt.web.SbtWeb$$anonfun$com$typesafe$sbt$web$SbtWeb$$load$1.apply(SbtWeb.scala:535)
at com.typesafe.sbt.web.SbtWeb$$anonfun$com$typesafe$sbt$web$SbtWeb$$load$1.apply(SbtWeb.scala:535)
at scala.Option.fold(Option.scala:157)
at com.typesafe.sbt.web.SbtWeb$.com$typesafe$sbt$web$SbtWeb$$load(SbtWeb.scala:549)
at com.typesafe.sbt.web.SbtWeb$$anonfun$globalSettings$1$$anonfun$apply$1.apply(SbtWeb.scala:143)
at com.typesafe.sbt.web.SbtWeb$$anonfun$globalSettings$1$$anonfun$apply$1.apply(SbtWeb.scala:143)
at scala.Function1$$anonfun$andThen$1.apply(Function1.scala:55)
at sbt.Project$.setProject(Project.scala:319)
at sbt.BuiltinCommands$.doLoadProject(Main.scala:484)
at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:475)
at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:475)
at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:58)
at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:58)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:60)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:60)
at sbt.Command$.process(Command.scala:92)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:98)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:98)
at sbt.State$$anon$1.process(State.scala:184)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:98)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:98)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.MainLoop$.next(MainLoop.scala:98)
at sbt.MainLoop$.run(MainLoop.scala:91)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:70)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:65)
at sbt.Using.apply(Using.scala:24)
at sbt.MainLoop$.runWithNewLog(MainLoop.scala:65)
at sbt.MainLoop$.runAndClearLast(MainLoop.scala:48)
at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:32)
at sbt.MainLoop$.runLogged(MainLoop.scala:24)
at sbt.StandardMain$.runManaged(Main.scala:53)
at sbt.xMain.run(Main.scala:28)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:129)
at xsbt.boot.Launch$.run(Launch.scala:109)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:36)
at xsbt.boot.Launch$.launch(Launch.scala:117)
at xsbt.boot.Launch$.apply(Launch.scala:19)
at xsbt.boot.Boot$.runImpl(Boot.scala:44)
at xsbt.boot.Boot$.main(Boot.scala:20)
at xsbt.boot.Boot.main(Boot.scala)
[error] java.lang.UnsupportedClassVersionError: com/typesafe/config/ConfigException : Unsupported major.minor version 52.0
[error] Use 'last' for the full log.
I have tried to search what this means, but the answers I find on google wont apply to my problem.
I have tried to select and deselect all of the options within SBT - Use auto-import, Download sources and docs etc.. But still the same error message.
Second try
Similar to first try, but I clicked "Create IntelliJ project" inside activator at localhost:8888 and then tried to import the project the same method as First try.
Third try
Open project and select the root directory, and I managed to import the project somewhat, but its moved project files to "project backup" and I got lots of warnings saying its based on a outdated version. Didn't quite understand this.
Fourth try
Create project from existing sources after creating the project at activator, and I got the project imported without warnings.
But when I open Application.java (or any other file for that matter), everything inside that file gets red underlined with a error saying similar to "Cannot resolve symbol 'Result'" and I cant compile anything.
I have tried to open modules and click + and add Scala as a module, but it doesn't seem to make any difference.
I really hope there is someone out there that can help me as this should be a fairly easy thing to install IntelliJ + Play framework.

The issue is that even if IntelliJ is set to use JDK8, the SBT process is using JDK7 (you can confirm that looking at it with a tool like JVisualVM). Not sure what their logic is to pick up SBT's JVM, but you can force it when you import the projet:
This solved it for me with this version of Idea:

From the documentation: https://www.playframework.com/documentation/2.4.x/Highlights24
Play 2.4 now requires JDK 8
So you definitely must use only JDK 8.
Unsupported major.minor version 52.0
Means that you try to open project that was compiled with JDK 8 but your settings in IDE is JDK 7 (or less)
My proposition - check twice if you really use JDK8 in the intelliJ

Related

Error during sbt execution: java.lang.NoClassDefFoundError: scala/StringContext

I am trying to run a play framework(2.1) application which is written in Scala but getting some error.
I need to use Play framework 2.1 only.
As per build.sbt file, I am using Scala 2.11.7.
sbt.version=0.13.8 is in project/build.properties.
I have installed Play 2.1.0 and changed my directory to application's root directory and then executed play command.
I got following error:
java.lang.NoClassDefFoundError: scala/StringContext
at sbt.CommandStrings$.<init>(CommandStrings.scala:83)
at sbt.CommandStrings$.<clinit>(CommandStrings.scala)
at sbt.BuiltinCommands$.defaults(Main.scala:202)
at sbt.xMain.run(Main.scala:29)
at xsbt.boot.Launch$.run(Launch.scala:55)
at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
at xsbt.boot.Launch$.launch(Launch.scala:69)
at xsbt.boot.Launch$.apply(Launch.scala:16)
at xsbt.boot.Boot$.runImpl(Boot.scala:31)
at xsbt.boot.Boot$.main(Boot.scala:20)
at xsbt.boot.Boot.main(Boot.scala)
Caused by: java.lang.ClassNotFoundException: scala.StringContext
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 11 more
Error during sbt exeenter code herecution: java.lang.NoClassDefFoundError: scala/StringContext
Can someone please tell me what's wrong here?
I am completely new to scala and I just need to run this app at earliest.
I am using 64-bit Cent OS 7(in case someone wants to know about OS).
The easiest way to fix that is to use an older version of SBT. Play 2.1.5 uses 0.12.2 by default, so you can change the file project/build.properties inside your project and use that version:
sbt.version=0.12.2
You can later try newer versions of SBT if you need.
sbt.version=0.12.2 wont work with JDK8 so you might need to downgrade Java.
I used this sbt version and got the following error
eror: error while loading CharSequence, class file '/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar(java/lang/CharSequence.class)' is broken for sbt 0.12.2

Apache Spark installation fails

I'm trying to install Apache Spark standalone on Ubuntu and while running "sbt/sbt assembly" command, I get this error:
java.lang.RuntimeException: Could not create directory /opt/spark-1.5.1/external/zeromq/target/streams/compile/$global/$global/discoveredMainClasses
at scala.sys.package$.error(package.scala:27)
at sbt.IO$.createDirectory(IO.scala:166)
at sbt.IO$.touch(IO.scala:142)
at sbt.std.Streams$$anon$3$$anon$2.make(Streams.scala:129)
at sbt.std.Streams$$anon$3$$anon$2.binary(Streams.scala:116)
at sbt.SessionVar$$anonfun$persist$1.apply(SessionVar.scala:27)
at sbt.SessionVar$$anonfun$persist$1.apply(SessionVar.scala:26)
at sbt.std.Streams$class.use(Streams.scala:75)
at sbt.std.Streams$$anon$3.use(Streams.scala:100)
at sbt.SessionVar$.persist(SessionVar.scala:26)
at sbt.SessionVar$.persistAndSet(SessionVar.scala:21)
at sbt.Project$RichTaskSessionVar$$anonfun$storeAs$1$$anonfun$apply$5.apply(Project.scala:556)
at sbt.Project$RichTaskSessionVar$$anonfun$storeAs$1$$anonfun$apply$5.apply(Project.scala:556)
at sbt.SessionVar$$anonfun$1$$anonfun$apply$1.apply(SessionVar.scala:40)
at sbt.SessionVar$$anonfun$1$$anonfun$apply$1.apply(SessionVar.scala:40)
at scala.Function$$anonfun$chain$1$$anonfun$apply$1.apply(Function.scala:24)
at scala.Function$$anonfun$chain$1$$anonfun$apply$1.apply(Function.scala:24)
at scala.collection.IndexedSeqOptimized$class.foldl(IndexedSeqOptimized.scala:51)
at scala.collection.IndexedSeqOptimized$class.foldLeft(IndexedSeqOptimized.scala:60)
at scala.collection.mutable.ArrayBuffer.foldLeft(ArrayBuffer.scala:47)
at scala.collection.TraversableOnce$class.$div$colon(TraversableOnce.scala:138)
at scala.collection.AbstractTraversable.$div$colon(Traversable.scala:105)
at scala.Function$$anonfun$chain$1.apply(Function.scala:24)
at sbt.EvaluateTask$.applyResults(EvaluateTask.scala:370)
at sbt.EvaluateTask$.liftedTree1$1(EvaluateTask.scala:344)
at sbt.EvaluateTask$.run$1(EvaluateTask.scala:341)
at sbt.EvaluateTask$.runTask(EvaluateTask.scala:361)
at sbt.Aggregation$$anonfun$3.apply(Aggregation.scala:64)
at sbt.Aggregation$$anonfun$3.apply(Aggregation.scala:62)
at sbt.EvaluateTask$.withStreams(EvaluateTask.scala:293)
at sbt.Aggregation$.timedRun(Aggregation.scala:62)
at sbt.Aggregation$.runTasks(Aggregation.scala:71)
at sbt.Aggregation$$anonfun$applyTasks$1.apply(Aggregation.scala:32)
at sbt.Aggregation$$anonfun$applyTasks$1.apply(Aggregation.scala:31)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:60)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:60)
at sbt.Aggregation$$anonfun$evaluatingParser$4$$anonfun$apply$5.apply(Aggregation.scala:153)
at sbt.Aggregation$$anonfun$evaluatingParser$4$$anonfun$apply$5.apply(Aggregation.scala:152)
at sbt.Act$$anonfun$sbt$Act$$actParser0$1$$anonfun$sbt$Act$$anonfun$$evaluate$1$1$$anonfun$apply$10.apply(Act.scala:244)
at sbt.Act$$anonfun$sbt$Act$$actParser0$1$$anonfun$sbt$Act$$anonfun$$evaluate$1$1$$anonfun$apply$10.apply(Act.scala:241)
at sbt.Command$.process(Command.scala:92)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:98)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:98)
at sbt.State$$anon$1.process(State.scala:184)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:98)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:98)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.MainLoop$.next(MainLoop.scala:98)
at sbt.MainLoop$.run(MainLoop.scala:91)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:70)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:65)
at sbt.Using.apply(Using.scala:24)
at sbt.MainLoop$.runWithNewLog(MainLoop.scala:65)
at sbt.MainLoop$.runAndClearLast(MainLoop.scala:48)
at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:32)
at sbt.MainLoop$.runLogged(MainLoop.scala:24)
at sbt.StandardMain$.runManaged(Main.scala:53)
at sbt.xMain.run(Main.scala:28)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
at xsbt.boot.Launch$.run(Launch.scala:109)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
at xsbt.boot.Launch$.launch(Launch.scala:117)
at xsbt.boot.Launch$.apply(Launch.scala:18)
at xsbt.boot.Boot$.runImpl(Boot.scala:41)
at xsbt.boot.Boot$.main(Boot.scala:17)
at xsbt.boot.Boot.main(Boot.scala)
[error] Could not create directory /opt/spark-1.5.1/external/zeromq/target/streams/compile/$global/$global/discoveredMainClasses
[error] Use 'last' for the full log.
Has anyone else faced this problem?
java version "1.8.0_65"
Scala code runner version 2.11.7 -- Copyright 2002-2013, LAMP/EPFL
As the error mentions you do not have write access to the /opt directory.
Could not create directory /opt/spark-1.5.1/external/zeromq/target/streams/compile/$global/$global/discoveredMainClasses
You need root access in order to write to this folder.
You can either
Download and compile Apache Spark to your home folder and then move it to /opt
Run sudo sbt/sbt assembly to gain root access while building spark (it is considered unsafe compiling as root)
You must have root privileges to add and manipulate /opt/ files. Spark configuration is wrong. I recommend follow these steps to install spark and scala, then try to run sbt. all the best. https://www.youtube.com/watch?v=BozSL9ygUto
We get this error inconsistently. It may be caused by an internal SBT bug.
"It seems like there is a race condition in SBT which is triggered only by plugins that cause multiple compilation processes to run in parallel."
See here for more info: https://github.com/sbt/sbt/issues/1673
See if you can disable some plugins and re-run.

Error building Intellij Scala Plugin

I am trying to follow the instructions at
https://confluence.jetbrains.com/display/SCA/Setting+up+Scala+plugin+project+in+IntelliJ+IDEA
I am using Idea 14.1.14.
Have downloaded the sources and downloadIdea.
And after importing the project set the Project SDK to 1.7.
Not sure if the above is enough info to go on; but on make project I get the below error; is it possible to guess at what I've got incorrect?
Error:scalac: error while loading Object, Missing dependency 'object scala in compiler mirror', required by /usr/lib/jvm/java-7-oracle/jre/lib/rt.jar(java/lang/Object.class)
Error:scalac: Error: object scala in compiler mirror not found.
scala.reflect.internal.MissingRequirementError: object scala in compiler mirror not found.
at scala.reflect.internal.MissingRequirementError$.signal(MissingRequirementError.scala:17)
at scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:18)
at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:53)
at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:66)
at scala.reflect.internal.Mirrors$RootsBase.getPackage(Mirrors.scala:173)
at scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackage$lzycompute(Definitions.scala:161)
at scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackage(Definitions.scala:161)
at scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackageClass$lzycompute(Definitions.scala:162)
at scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackageClass(Definitions.scala:162)
at scala.reflect.internal.Definitions$DefinitionsClass.init(Definitions.scala:1377)
at scala.tools.nsc.Global$Run.<init>(Global.scala:1229)
at xsbt.CachedCompiler0$$anon$2.<init>(CompilerInterface.scala:116)
at xsbt.CachedCompiler0.run(CompilerInterface.scala:116)
at xsbt.CachedCompiler0.run(CompilerInterface.scala:102)
at xsbt.CompilerInterface.run(CompilerInterface.scala:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:102)
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:48)
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:41)
at org.jetbrains.jps.incremental.scala.local.IdeaIncrementalCompiler.compile(IdeaIncrementalCompiler.scala:29)
at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:26)
at org.jetbrains.jps.incremental.scala.remote.Main$.make(Main.scala:62)
at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:20)
at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)
Warning:scalac: No 'scala-library*.jar' in module dependencies [compiler_settings]
Go to File -> Project structure -> Global libraries and add Scala SDK there. In my case, two SDKs were already present (in ivy folder) and offered for selection.
I have faced a similar issue recently even after having the compatible versions of java,sbt and scala SDK but found few reasons why we get this error when we importing sbt project into Intellij.
Check the scala-SDK is present in the global libraries under File->Project Structure -> Global Libraries.
Please find the below screenshot.
Even after fixing the first issue you still face this issue. Then look for the external dependencies which you have placed under /lib folder check the checksum of that jar if possible are make sure it has the right size. This should solve the issue.
Apart from the above issue, you might end up with dependencies source linking issues in the code when you open the project in IntelliJ. This is because of the additional root modules which are present under File -> Project modules -> modules. In the modules panel, you will see projectxxx-src and projectxx-test additional to projexctxx-process and projectxx-process-build. So remove the projectxx-src and projectxx-test.
You have to have Java 8 JDK for Scala to work
see the scala site for further info
Only Java 8 JDK version should be used along side scala. Not even higher JDK versions.
better also check here. It solved my own building errors
In my case, I had to specify the correct JDK home path in the Project structure -> SDKs.
Since my JAVA_HOME variable was not set yet, Intellij was taking a default value which doesn't exist.
Replace the JDK Home Path by the the right path of the JDK (in my case it was the following : /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home)
Replace 'adoptopenjdk-8.jdk' by your folders' name (might be jdk_1.8.0_xxx.jdk)
I hope it helps.
Double-Check JDK Compatibility
I encountered this issue when the Java SDK being used by my IntelliJ project was too "new" for the version of Scala I was using. For example, IntelliJ defaulted to using Java 12 for my project when my project was using Scala version 2.11.8. However, according to the documentation, the minimum required Scala version for JDK 11 is 2.11.12; therefore, I resolved this problem by changing the JDK used in IntelliJ to Java 8 by going to File -> Project Structure -> Project -> Project SDK

Why do i get a ClassNotFoundException on running a simple scala program on IntelliJ 14+?

I'm unable to figure out what is wrong with this program? I'm using an older verison of scala (2.7) because its compatible with certain libraries i'm using
Here is a simple program i'm attempting to run.
The program runs fine using scalac and scala commands.
However on IntelliJ 14+ -> when i create a new project -> select the compiler (scala 2.7) and try to run the above program i get this error below
object SimpleClass {
def main(args: Array[String]) {
println("This is a simple Class")
}
}
Error output.
Why does intelliJ throw the ClassNotFoundException? I've saved the program as SimpleClass.scala
/usr/lib/jvm/java-7-openjdk-i386/bin/java -Didea.launcher.port=7532 -Didea.launcher.bin.path=/home/tejesh/Downloads/idea-IC-141.1532.4/bin -Dfile.encoding=UTF-8 -classpath /usr/lib/jvm/java-7-openjdk-i386/jre/lib/javazic.jar:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/management-agent.jar:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/resources.jar:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/rhino.jar:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/charsets.jar:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/jce.jar:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/jsse.jar:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/rt.jar:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/compilefontconfig.jar:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/ext/java-atk-wrapper.jar:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/ext/icedtea-sound.jar:/usr/local/share/scala-2.7.3/lib/scala-swing.jar:/usr/local/share/scala-2.7.3/lib/scala-library.jar:/home/tejesh/Downloads/idea-IC-141.1532.4/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain SimpleClass
Exception in thread "main" java.lang.ClassNotFoundException: SimpleClass
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:191)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:122)
I've added the folder containing the SimpleClass as under sources
This is the full program here
Recent Scala for IntelliJ IDEA is based on sbt. Apparently Scala 2.7.3 is not supported any longer in this configuration. If you set up a project, IntelliJ will offer you (when you select "Download" for the SDK) no version older than Scala 2.8.0. If you manually select 2.7.3, the following happens when you try to compile:
Error:scalac: Error: org.jetbrains.jps.incremental.scala.remote.ServerException
Error compiling sbt component 'compiler-interface-2.7.3.final-52.0'
at sbt.compiler.AnalyzingCompiler$$anonfun$compileSources$1$$anonfun$apply$2.apply(AnalyzingCompiler.scala:145)
at sbt.compiler.AnalyzingCompiler$$anonfun$compileSources$1$$anonfun$apply$2.apply(AnalyzingCompiler.scala:142)
at sbt.IO$.withTemporaryDirectory(IO.scala:285)
at sbt.compiler.AnalyzingCompiler$$anonfun$compileSources$1.apply(AnalyzingCompiler.scala:142)
at
...
The next step is Scala 2.8.2, for which you get:
Error:scalac: Parameter '-nobootcp' is not recognised by Scalac.
It seems the oldest Scala that works with the current IntelliJ is 2.9.0. (You have to use Java 7 and not Java 8 for this!)
The solution would be to downgrade IntelliJ IDEA to an old version that still supports Scala 2.7.3 (perhaps IDEA 11?), or to simply set up the project with Scala 2.9.3, but compile instead manually (or using sbt from the terminal) against 2.7.3.
If you have the source to the library that requires 2.7.3, perhaps the best option is to try to compile the library with contemporary versions of Scala (at least 2.9.0).

sbt 0.13.0 JLine incompatibility detected

I have a problem with starting a play 2.2.0 app on my mac with mountain lion and java 7:
[ERROR] Terminal initialization failed; falling back to unsupported
java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected
at jline.TerminalFactory.create(TerminalFactory.java:101)
at jline.TerminalFactory.get(TerminalFactory.java:159)
at sbt.ConsoleLogger$.ansiSupported(ConsoleLogger.scala:85)
at sbt.ConsoleLogger$.<init>(ConsoleLogger.scala:79)
at sbt.ConsoleLogger$.<clinit>(ConsoleLogger.scala)
at sbt.GlobalLogging$.initial(GlobalLogging.scala:40)
at sbt.StandardMain$.initialGlobalLogging(Main.scala:54)
at sbt.StandardMain$.initialState(Main.scala:60)
at sbt.xMain.run(Main.scala:26)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:57)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:77)
at xsbt.boot.Launch$.run(Launch.scala:57)
at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
at xsbt.boot.Launch$.launch(Launch.scala:65)
at xsbt.boot.Launch$.apply(Launch.scala:16)
at xsbt.boot.Boot$.runImpl(Boot.scala:32)
at xsbt.boot.Boot$.main(Boot.scala:21)
at xsbt.boot.Boot.main(Boot.scala)
java.lang.IncompatibleClassChangeError: JLine incompatibility detected. Check that the sbt launcher is version 0.13.x or later.
at sbt.ConsoleLogger$.ansiSupported(ConsoleLogger.scala:96)
at sbt.ConsoleLogger$.<init>(ConsoleLogger.scala:79)
at sbt.ConsoleLogger$.<clinit>(ConsoleLogger.scala)
at sbt.GlobalLogging$.initial(GlobalLogging.scala:40)
at sbt.StandardMain$.initialGlobalLogging(Main.scala:54)
at sbt.StandardMain$.initialState(Main.scala:60)
at sbt.xMain.run(Main.scala:26)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:57)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:77)
at xsbt.boot.Launch$.run(Launch.scala:57)
at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
at xsbt.boot.Launch$.launch(Launch.scala:65)
at xsbt.boot.Launch$.apply(Launch.scala:16)
at xsbt.boot.Boot$.runImpl(Boot.scala:32)
at xsbt.boot.Boot$.main(Boot.scala:21)
at xsbt.boot.Boot.main(Boot.scala)
Error during sbt execution: java.lang.IncompatibleClassChangeError: JLine incompatibility detected. Check that the sbt launcher is version 0.13.x or later.
It's not really linked to play since I got the same error when I start directly sbt in that directory.
So I tried a couple of things:
removed all sbt related stuff from my home dir and tried to use the sbt script from https://github.com/paulp/sbt-extras/blob/master/sbt -> same problem
removed all jars from my ivy repo dir and started again sbt -> same problem
downloaded a sbt launcher directly (version 0.13.0) -> same problem
tried with java 6 -> same problem
tried to debug sbt to figure out what's wrong but all I found out was that jline does not recognize that it should use a UnixTerminal (which I got working by setting systemProperties) but then again -> same error
It's somehow related to some strange linking I think because the class version for the terminal which should be used seems to be old. At least this is what the jvm is complaining about.
I tried it on a virtual box with ubuntu which worked fine so I think my system is a mess or I did something completely wrong.
Someone any ideas?
I had same problem. My project is using SBT 0.13
Turned out I need to upgrade SBT Launcher to 0.13 version as well.
If you start the JVM with verbose class loading enabled (-verbose:class), that might help troubleshoot where the offending JLine classes are coming from. Perhaps you have a JLine jar in one of your JVM extension directories, probably ~/Library/Java/Extensions or /System/Library/Java/Extensions.
This error can also happen if you use an SBT launcher from 0.12 in an SBT 0.13 project, as suggested in the error message.
Try updating SBT version to 0.13. Just download the sbt tar file and change the path in your .bash_profile file. Try again running sbt command in the project directory. That should fix the issue.