Search code examples
javaplayframeworksbtsimplejson

java Play add jar to lib


I'm trying to add org.json.simple.

I have created my lib folder in root and added the jar file and restarted my project with sbt run.

I still get package org.json.simple does not exist.

I tried to add to the build.sbt (this did not work):

libraryDependencies += "org.json.simple.JSONArray% "JSONArray" % "3.1.1"
libraryDependencies += "org.json.simple.JSONObject% "JSONObject" % "3.1.1"

IDE: VS Code

System: MAC


Solution

  • You need to add dependencies to libaries in libraryDependencies. Right now, you are trying to specify classes, which will not work.

    Instead, you need to use

    libraryDependencies += "com.github.cliftonlabs" % "json-simple" % "3.1.1"
    

    Note that above dependency is probably not the one you need, as it uses a different package and class names, I picked it as it has the same version as you specify. Maybe you need to use "com.googlecode.json-simple" % "json-simple" % "1.1.1" instead.