Here is a simple test I'm using to invoke a Scala method from Java:
public static void main(String args[]) {
java.util.Map<String, java.util.List<String>> rec = news.recommend.DriverObj.runTest();
System.out.println(rec.toString());
}
Here is the definition of the Scala method:
def runTest: java.util.Map[String, java.util.List[String]] = {
new java.util.HashMap[String, java.util.List[String]]
}
But it throws an error:
Exception in thread "main" java.lang.NoClassDefFoundError: scala/Function1
at news.recommend.DriverObj.runTest(DriverObj.scala)
What should I do to make this running smoothly?
Update : I'm running it via Eclipse and my build path contains :
So Scala library should be found ?
scala
includes it automatically,java
does not. – Ethelscala-library.jar
as a library to your Eclipse project, the way you add any normal jar when using Java. – Blockade