Scala IDE is not working - scala could not find or load main class - scala

I try to run a simple scala spark program but somehow its throwing me a scala could not find load main class error. Any idea?

Related

Unable to run a standlone scala file

I'm following examples out of Programming in Scala book by Odersky and I'm unable to run a simple standalone scala file with scala hello.scala. When I do this, I get this error:
Error: Could not find or load main class hello.scala
Caused by: java.lang.ClassNotFoundException: hello.scala
I'm using scala3.
Here's a state of my file and commands I'm running.
If you follow the steps from the documentation you'll see that you need to compile your file before running it.
If you run:
scalac hello.scala
scala hello
You should get the result you want.
you might consider using the new (and excellent) tool from virtuslab called 'scala-cli': https://scala-cli.virtuslab.org/

Could not find or load main class Error when changing scala compiler version

The default version of Scala complier of Scala IDE for eclipse is 2.12. It runs well for hello world.
However when I change the Scala complier version to 2.11 like following:
Then it shows Error: Could not find or load main class
When I change back to 2.12, it works again.
My question:
My Scala IDE for eclipse version is latest. Why this happens? And what should I do? I have to change to scala 2.11 to load the apache-spark 2.4 jar files. Otherwise it will show errors.

opencv 3.0.0 java imread_0 undefined

I am trying to develop an application using java opencv 3.0.0-beta using scala.
I am getting a runtime error:
java.lang.UnsatisfiedLinkError: java.lang.UnsatisfiedLinkError: org.opencv.imgcodecs.Imgcodecs.imread_1(Ljava/lang/String;)J
While researching the cause i have created the following simple application the exhibits similar behaviour:
import reflect._
import org.opencv.core.Core
import org.opencv.core.Mat
import org.opencv.core.CvType
import org.opencv.imgcodecs.Imgcodecs
object main extends Application {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME)
val what = "something.png"
val mat = Imgcodecs.imread(what)
Imgcodecs.imwrite("something_else.png", mat)
}
The major difference is that, if run as "sbt run" it performs as expected. if the appropriate lines are removed from the above the code fails in REPL.
I suspect that this issue is related to the original issue, but have no proof.
If i look at the memory map of the JVM in both cases i have the expected libs loaded.
If the code is inspected i find no definition of org.opencv.imgcodecs.Imgcodecs.imread_1
I am quite lost as to where to go next in diagnosing this issue.
Is there anyone who has come across this issue?
Thanks
i haven't used openCV3.0 yet, as it has major changes and breaks opencv 2.4.x code , are you supplying the library path to
sbt run
add
javaOptions in run += "-Djava.library.path=lib/opencv/"
to your build.sbt file or pass on cmd line
sbt run -Djava.library.path=lib/opencv/
opencv folder should have your files that gets generated along with your jar file
i have java bindins for 2.4.9 , 2.4.10 and 3.0.0 for java 7 and 8 in this git repo if you need them
git#gitlab.com:opencv/java_lib.git

class java.lang.RuntimeException/Scala class file does not contain Scala annotation

I'm trying to execute a scala code using scala 2.10.2, the code uses some jar libraries compiled with sbt.
I get the following error:
scala: error while loading Order, class file '..\prestashop-scala-client-0.2.4\target\prestasac-0.2.4.jar(co/orderly/prestasac/representations/Order.class)' is broken
(class java.lang.RuntimeException/Scala class file does not contain Scala annotation)
Sources of the prestasac-0.2.4.jar are on github: Order.class
Is there something to do to fix this issue ?
Thank you
Looks like the library is configured to compile against Scala 2.9.1. Major versions of Scala are not binary compatible.
I put the necessary SBT changes here: https://github.com/mpartel/prestashop-scala-client/commit/e9a1df40bfe35518aaebac899e438b9b6fa6d728

sbt can't find scala.reflect.Manifest when getting Unidoc.scala settings with scala 2.10.0

I just updated my project to Scala 2.10.0 using SBT 0.12. But now, when running sbt, I get the following error:
java.lang.NoClassDefFoundError: scala/reflect/ManifestFactory$
at X.build.Unidoc$.<init>(Unidoc.scala:8)
at X.build.Unidoc$.<clinit>(Unidoc.scala)
at X.build.ServicesBuild$.<init>(Build.scala:25)
at X.build.ServicesBuild$.<clinit>(Build.scala)
It seems that the problem is on SettingKey:
8: val unidocDirectory = SettingKey[File]("unidoc-directory")
I heard that Scala 2.10 was doing reflects different than before and thought that that was the issue, yet the Akka project is doing the same exact thing and (I assume) they are doing fine.
https://github.com/akka/akka/blob/master/project/Unidoc.scala (my Unidoc.scala is pretty much a copy&paste of theirs).
Does anyone know what is happening? How can it not find a class in scala itself?
Thanks!