Can compile scala file but but run it


#1

I know i can use sbt to avoid all this problem but just for knowledge sake. I am not sure why i can compile the code but not able to run it.

My directory structure is as such:

$ ls io_monad/*
io_monad/Test.scala

io_monad/classes:
io_monad

io_monad/lib:
cats-core_2.12-0.9.0.jar cats-effect_2.12-0.7.jar

Simple Test.scala file

package io_monad

import cats.effect.IO

object Test extends App {

    val program:IO[Unit] = for {
        _         <- IO { println("First name?") }
        firstName <- IO { scala.io.StdIn.readLine }
        _         <- IO { println(s"Last name?") }
        lastName  <- IO { scala.io.StdIn.readLine }
        _         <- IO { println(s"First: $firstName, Last: $lastName") }
    } yield ()

    program.unsafeRunSync()
}

Compiling successful

$ scalac -cp "io_monad/lib/cats-core_2.12-0.9.0.jar:io_monad/lib/cats-effect_2.12-0.7.jar" -d io_monad/classes io_monad/Test.scala

But not the running of app

$ scala -cp "io_monad/lib/cats-core_2.12-0.9.0.jar:io_monad/lib/cats-effect_2.12-0.7.jar:io_monad/classes/" io_monad.Test
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
java.lang.ClassNotFoundException: cats.kernel.Semigroup

#2

Problem solved, it was lacking some other libraries


#3

Also posted at https://stackoverflow.com/q/48041006/1374461