I created a script of Scala with the following header
#!/bin/sh
exec scala "$0" "$@"
!#
import org.apache.spark.sql.{Dataset, SparkSession}
.....
.....
But there is the following error after running it.
error: object apache is not a member of package org import org.apache.spark.sql.{Dataset, SparkSession}
spark-shellin that manner, consider importing spark libs to classpath. Although I highly recommend the approach prince suggested.