2017-11-11 44 views
0

當我嘗試推出SBT,我得到以下信息:SBT無法找到的Java

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

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

然而,Java和斯卡拉安裝

~(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) 

這是斯卡拉

~(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> 

而且你可以在路徑中找到它們

Java的路徑

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路徑

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

和Scala路徑

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

我跑所有這些在MAC OS塞拉利昂v10.12.6 我感謝所有幫助。提前致謝。

回答

0

JAVA_HOME and PATH不應該指向相同的目錄。 JAVA_HOME指向Java目錄,PATH指向其bin子目錄。 例如,對於我

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

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)

+1

感謝您的幫助 – rumbo181

2

感謝你的回答,它幫了我很多。

最重要的是在grep的選項修復:

#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="" 

另外,我重寫正確路徑和變量設置。在我從zip文件中設置sbt的新安裝方式中,我包含了一個特定的別名以覆蓋以前的設置並在.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