pozharko
pozharko

Reputation: 33

Import Java library to Scala sbt project

I'm trying to use import guava library in SBT project (play framework), but can't compile my code

import com.google.common.net.InternetDomainName

class MyClass(link: String) {
  private val domains = {
    val host = new URL(link).getHost
    val domainName = InternetDomainName.from(host)
    domainName.topPrivateDomain().name()
  }
}

I get compilation error

object google is not a member of package com

Can anyone explain, what is the problem?

Upvotes: 3

Views: 7193

Answers (1)

mavilein
mavilein

Reputation: 11668

Have you added the guava library as a library dependency to your build.sbt file? You can find that file in the project's root directory. There you can add the dependency to the guava library:

libraryDependencies ++= Seq(
  "com.google.guava" % "guava" % "17.0",
  // other dependencies separated by commas
)

Upvotes: 13

Related Questions