Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 595
pozharko Avatar asked Dec 01 '25 03:12

pozharko


1 Answers

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
)
like image 122
mavilein Avatar answered Dec 02 '25 19:12

mavilein



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!