2018년 11월 1일 목요일

[TroubleShooting] sbt could not find or load main class file

Have you gotten this error message, when you execute sbt in git bash?

Error: Could not find or load main class file
Caused by: java.lang.ClassNotFoundException: file


But the problem is that it works in Windows CMD, but it doesn't work only git bash

So I tried to find solution in google, and I got a solution like this
In short, Change the path that "C:\Program Files" to "C:\Progra~1" and "C:\Program File(x86)" to "C:\Progra~2". because git shell can't recognize space and special character such as () in path.

So I generated environment varaibles like below

And I changed SBT and Git path to the variables.

But It still doesn't work

So I found another way and I did it.(another way)
In short, you should execute sbt.bat not sbt

It works fine!


But typing sbt.bat is so annoying, I wanted to type only "sbt"

So I set alias in git bash like below

$> vi ~/.bashrc

Add "alias sbt 'sbt.bat'" in .bashrc
Apply the script
$> source ~/.bashrc

Now, It works even if you type "sbt"

댓글 없음:

댓글 쓰기

[TroubleShooting] sbt could not find or load main class file

Have you gotten this error message, when you execute sbt in git bash? Error: Could not find or load main class file Caused by: java.lang....