Why do I get `java.lang.NoClassDefFoundError: scala/Function1` when I run my code in ScalaIDE?

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();     

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 ?


adding the Scala dependency to the maven build can fix the issue :


As for me, in the configuration of "Run/Debug configurations" [idealJ]

remember to choose the "Include dependencies with "Provided" scope"

Need Your Help

Spring get files and images from external folder on disk, outside webapps?

java spring resources external

I have webproject which has images inside src/main/webapp folder. I would like to place images in different folder on the disk. But I have no idea how to manage requests to reach this images.

Python: Split a list into smaller jsons based on another list

python list python-3.x

I have one list of program names which need to be sorted into lists of smaller jsons based of a priority list. I need to do this in python 3.