How can I compile and run kts file with certain cl...
# announcements
i
How can I compile and run kts file with certain classpath?
m
Copy code
▶ kotlin -h
kotlin: run Kotlin programs, scripts or REPL.

Usage: kotlin <options> <command> <arguments>
where command may be one of:
  foo.Bar                    Runs the 'main' function from the class with the given qualified name
  app.jar                    Runs the given JAR file as 'java -jar' would do
                             (-classpath argument is ignored and no Kotlin runtime is added to the classpath)
and possible options include:
  -classpath (-cp) <path>    Paths where to find user class files
  -Dname=value               Set a system JVM property
  -J<option>                 Pass an option directly to JVM
  -no-reflect                Don't include Kotlin reflection implementation into classpath
  -version                   Display Kotlin version
  -help (-h)                 Print a synopsis of options
the option you want is
-cp
just like
javac
, but you don’t want to this manually. Instead use a build tool like maven or gradle.