2

When I try to launch sbt, I get the following message:

~(501)$sbt
(standard_in) 1: parse error

No java installations was detected.
Please go to http://www.java.com/getjava/ and download

However, both Java and Scala are installed

~(508)$java -version
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)

And this is Scala

~(503)$scala
Welcome to Scala 2.12.4 (Java HotSpot(TM) 64-Bit Server VM, Java 9.0.1).
Type in expressions for evaluation. Or try :help.

scala> 

And you can find them in the path

Java path

export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/"     
export PATH=$PATH:"/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/"   

Sbt path

export SBT_HOME="/usr/local/Cellar/sbt/1.0.3/bin/" 
export PATH=$PATH:$SBT_HOME

and Scala path

export SCALA_HOME="/usr/local/opt/scala/idea"
export PATH=$PATH:$SCALA_HOME/bin

I'm running all these in a Mac Os Sierra v10.12.6 I'll appreciate any help. Thanks in advance.

rumbo181
  • 43
  • 1
  • 5

2 Answers2

2

Thanks for your answer, It helped me a lot.

Most important was a fix on the grep options:

   #GREP_OPTIONS="--color=always";export GREP_OPTIONS
   #pay attention - don't use previous line or sbt for scala won't work,
   #this is the reason why to keep active the following line
   GREP_OPTIONS=""

In addition, I rewrite properly paths and variable settings. In the way I set a fresh install of sbt from zip file, so I included a specific alias to override previous settings and launch it in .bash_profile

### Java 
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home"
export PATH=$PATH:$JAVA_HOME/bin

### SBT
#alias is to force launch from fresh install from .zip file
alias sbt="~/sbt/bin/sbt"
export SBT_HOME="~/sbt"
export PATH=$PATH:$SBT_HOME/bin
rumbo181
  • 43
  • 1
  • 5
1

JAVA_HOME and PATH shouldn't point to the same directory. JAVA_HOME points to Java directory and PATH to its bin subdirectory. For example for me

$ echo $JAVA_HOME
/usr/lib/jvm/java-8-oracle
$ echo $PATH
...:/usr/lib/jvm/java-8-oracle/bin:...

See also

Why does sbt report "No java installations was detected" with $JAVA_HOME set?

No Java installation was detected while sbt update

https://apple.stackexchange.com/questions/163418/no-java-installations-was-detected-although-i-have-java

Installing Java on OS X 10.9 (Mavericks)

Dmytro Mitin
  • 48,194
  • 3
  • 28
  • 66