Search code examples
scalamavensbtjfreechart

How to declare Maven/Java library, e.g. JFreeChart, as dependency?


I'm trying to add JFreeChart library as a dependency of a sbt project.

I added the following to build.sbt:

libraryDependencies += "org.jfree" %% "jfreechart" % "1.0.14"

However, it doesn't work.

The pom file at http://central.maven.org/maven2/org/jfree/jfreechart/1.0.14/jfreechart-1.0.14.pom says:

<artifactId>jfreechart</artifactId>
<groupId>org.jfree</groupId>
<version>1.0.14</version>

How can I use a maven library like this in sbt?


Solution

  • You've used %% before the artifactId, which causes SBT to append the version of scala. So you're actually trying to find the artifact that has an id of jfreechart_2.10 (or whatever your version of Scala is).

    This is useful for cross built libraries. Java libraries are not cross built, so use:

    libraryDependencies += "org.jfree" % "jfreechart" % "1.0.14"