billybob billybob - 4 months ago 48
Scala Question

sbt.bat for windows

I'm new to Scala.

I just installed sbt for windows MSI

I have a project with build.sbt

I opened a windows console in the current project folder.

I runned the sbt.bat

I turned @echo on to get the error message.

C:\MasseGuillaume-Scala99-1879ed7>sbt

C:\MasseGuillaume-Scala99-1879ed7>set SBT_HOME=C:\MasseGuillaume-Scala99-1879ed7
\

C:\MasseGuillaume-Scala99-1879ed7>set ERROR_CODE=0

C:\MasseGuillaume-Scala99-1879ed7>rem We use the value of the JAVACMD environmen
t variable if defined

C:\MasseGuillaume-Scala99-1879ed7>set _JAVACMD=

C:\MasseGuillaume-Scala99-1879ed7>if "" == "" (if not "" == "" (if exist "\bin\j
ava.exe" set "_JAVACMD=\bin\java.exe" ) )

C:\MasseGuillaume-Scala99-1879ed7>if "" == "" set _JAVACMD=java

C:\MasseGuillaume-Scala99-1879ed7>rem We use the value of the JAVA_OPTS environm
ent variable if defined

C:\MasseGuillaume-Scala99-1879ed7>set _JAVA_OPTS=

C:\MasseGuillaume-Scala99-1879ed7>if "" == "" set _JAVA_OPTS=-Xmx512M -XX:MaxPer
mSize=256m -XX:ReservedCodeCacheSize=128m -Dsbt.log.format=true

C:\MasseGuillaume-Scala99-1879ed7>"java" -Xmx512M -XX:MaxPermSize=256m -XX:Reser
vedCodeCacheSize=128m -Dsbt.log.format=true -cp "C:\MasseGuillaume-Scala99-1879
ed7\jansi.jar;C:\MasseGuillaume-Scala99-1879ed7\sbt-launch.jar;C:\MasseGuillaume
-Scala99-1879ed7\classes" SbtJansiLaunch
'"java"' n'est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.

C:\MasseGuillaume-Scala99-1879ed7>if ERRORLEVEL 1 goto error

C:\MasseGuillaume-Scala99-1879ed7>set ERROR_CODE=1

C:\MasseGuillaume-Scala99-1879ed7>exit /B


the error is in this line :

"%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -cp "%SBT_HOME%jansi.jar;%SBT_HOME%sbt-launch.jar;%SBT_HOME%classes" SbtJansiLaunch %*


What should I add to fix it ? The error says that it's Java is not recognized as an internal or an external command or programm.

I just don't get the message error. If I put the sbt.bat and jansi.jar and sbt-launch.jar in the C:\Program Files (x86)\Java\jre6\bin and i run the batch file, it's working.

Any solutions ?

Answer

I'll admit that I haven't done much French in the thirty-odd years since I left school but:

'"java"' n'est pas reconnu en tant que commande interne ou externe, un programme exécutable ou un fichier de commandes.

looks suspiciously like the old favorite "something is not recognised as an internal command, executable program or batch file" (or something like that) that Windows tosses out when it can't find what you're trying to run.

Sounds like you need to install a Java runtime environment, or modify your path to point to one that's already installed. Since you apparently have a C:\Program Files (x86)\Java\jre6\bin directory, I'd suggest the latter.

Go in to the control panel, select System then Advanced System Settings, choose the Advanced tab, then the Environment Variables button.

Then modify your path to include the JRE bin directory. After saving that, open another cmd window and verify it with path. That's needed to check (and use) the new path since it only affects new sessions, not existing ones.

Note those instructions are for Win 7, it may vary a little on other versions but the concept will be the same.

Alternatively, if you don't want to fiddle with the path in your control panel, you can change it in that batch file with something like:

set path="%path%;C:\Program Files (x86)\Java\jre6\bin"

That way, it will only be in effect when you're running the batch file.