1
votes

I am attempting to use the Eclipse Scala-IDE for 2.11 (downloaded the prepackaged bundle from the web-site). I have been using the Scala Worksheet to work with a SaaS API returning JSON. I've been pushing through just using String methods. I decided to begin using json4s. I went to http://mvnrepository.com/ and obtained the following libraries:

  • json4s-core-2.11-3.2.10.jar
  • json4s-native-2.11-3.2.10.jar
  • paranamer-2.6.jar

I have added all three jars to the Project's Build Path. And they appear under the project's "Referenced Libraries".

I have the following code in a Scala Worksheet:

package org.public_domain

import org.json4s._
import org.json4s.native.JsonMethods._

object WorkSheet6 {
  println("Welcome to the Scala worksheet")
  parse(""" { "numbers" : [1, 2, 3, 4] } """)
  println("Bye")
}

I am receiving the following two compilation errors:

  • bad symbolic reference to org.json4s.JsonAST.JValue encountered in class file 'package.class'. Cannot access type JValue in value org.json4s.JsonAST. The current classpath may be missing a definition for org.json4s.JsonAST.JValue, or package.class may have been compiled against a version that's incompatible with the one found on the current classpath.
  • bad symbolic reference to org.json4s.JsonAST.JValue encountered in class file 'package.class'. Cannot access type JValue in value org.json4s.JsonAST. The current classpath may be missing a definition for org.json4s.JsonAST.JValue, or package.class may have been compiled against a version that's incompatible with the one found on the current classpath.

When I go look in the org.json4s package in the json4s-core-2.11-3.2.10.jar file, there is in fact no .class file indicating any sort of compiled object JsonAST.

This is a showstopper. Any help on this would be greatly appreciated.

1

1 Answers

5
votes

Your classpath is incomplete. You are missing a dependency of json4s-core.

bad symbolic reference to org.json4s.JsonAST.JValue encountered in class file 'package.class'. Cannot access type JValue in value org.json4s.JsonAST. The current classpath may be missing a definition for org.json4s.JsonAST.JValue, or package.class may have been compiled against a version that's incompatible with the one found on the current classpath.

The simplest way to consume Scala or Java libraries is to use sbt or maven. They bring in (transitive) dependencies for you. If you check the pom definition of json4s-core library, you notice it depends on json4s-ast. You should add that jar to your build path as well.