Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coursera - Functional Programming Principles in Scala - can't work with example project because of errors

Tags:

windows

scala

sbt

From that course https://class.coursera.org/progfun-004/assignment

i downloaded http://spark-public.s3.amazonaws.com/progfun/assignments/example.zip

Imported this to Intellij Idea.

But the problem is to verify code, because in course they running sbt in console...

After run "sbt" in console i get:

D:\learning\example>sbt
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading project definition from D:\learning\example\project\project
error: error while loading CharSequence, class file 'C:\Program Files\Java\jdk1.8.0_05\jre\lib\rt.jar(java/lang/CharSequence.cl
ass)' is broken
(bad constant pool tag 15 at byte 1501)
[error] Type error in expression
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? q

I created new project in Intellij Idea with SBT and it works... but version of SBT is other then in example project. But when i changing version of SBT to newest i get dependency errors... I stack and can't move... How to solve situation like that?

I guess i can try move all project to Java8 or force sbt in my console to works with Java7. I don't know how to do both :)

like image 627
kabra Avatar asked Jun 29 '14 16:06

kabra


1 Answers

I believe you're getting this issue because Scala prior 2.10.4 doesn't support JDK8. There is an issue on github describing the problem. You have to downgrade to Java 7.

If you're running sbt on Linux you can set the -java-home parameter.

  $ sbt -help
  # java version (default: java from PATH, currently java version "1.7.0_60")
  -java-home <path>         alternate JAVA_HOME

On Windows however it's not that easy.

Sbt uses sbt.bat to run sbt on Windows. You can find it by writing where sbt in windows console.

C:\Users\lpiepiora>where sbt
C:\Program Files\sbt\bin\sbt
C:\Program Files\sbt\bin\sbt.bat

Now you can edit C:\Program Files\sbt\bin\sbt.bat and at the beginning of the file just after

@REM SBT launcher script
@REM 
@REM Envioronment:
@REM JAVA_HOME - location of a JDK home dir (mandatory)
@REM SBT_OPTS  - JVM options (optional)
@REM Configuration:
@REM sbtconfig.txt found in the SBT_HOME.

add

set JAVA_HOME="C:\Program Files\...<path to your Java 7>"

If you're running sbt, restart it. Confirm the version you're running by typing about in the sbt command line.

like image 194
lpiepiora Avatar answered Nov 03 '22 19:11

lpiepiora