-1

I am facing issue with using rocksDb library in scala.

I'm trying to import org.rocksdb.RocksDB; in my code but I keep hitting with this error:

object rocksdb is not a member of package org.

I searched online and found that using build.sbt and including the library dependency might solve the issue but I have no idea which version to use. I have seen examples of build.sbt for flink and other use cases but not in scala. Any leads on this is highly appreciated.

Razor21
  • 59
  • 1
  • 6
  • 1
    Most projects bigger than hello-world require the use of a build-tool. Popular build-tools for Scala projects are `sbt`, `maven` and `gradle`. And each of these build tools have their own way of adding dependency libraries to the project. So, the first question is - which build tool are you even using for your project ? – sarveshseri Oct 05 '19 at 21:15

1 Answers1

1

In most cases, projects bigger than hello-world require the use of a build-tool.

Popular build-tools for Scala projects are sbt, maven and gradle.

Each of these build tools have their own way of adding dependency libraries to the project.

So, the first question is - which build tool are you even using for your project ?

In case of sbt, then the project configuration is done using build.sbt file.

A basic sbt project looks like following,

YourProject
├── build.sbt
├── project
│   └── build.properties
└── src
    └── main
        └── scala
            └── YouCode.scala

You can create this structure manually or if you are using IntelliJ Idea, You can create a new sbt project simply by using File -> New -> Project -> Scala -> sbt.

As a beginner, I will strongly suggest that you use IntelliJ Idea with Scala plugin. That will help you in simplifying a lot of things.

For more details on setting things up both using intellj and sbt- https://www.scala-lang.org/download/ .

The project/build.properties provides the sbt version used for this project,

sbt.version = 1.3.0

A bare bone build.sbt looks like following,

name := "YourProject"

version := "1.0"

scalaVersion := "2.12.8"

Now, In your newly created project, you can add the rocks-db library (and other libs) as dependency by adding following to your build.sbt,

libraryDependencies ++= Seq(
  "org.rocksdb" % "rocksdbjni" % "6.2.2",
  "some.other" % "some-dependecy" % "other-version",
  ...
)

I have included the version "6.2.2" in here. As for which version of rocksdb library, that will depend on the version of rocksdb you are connecting to it. Best is to choose the same version as the rocksdb version.

sarveshseri
  • 13,738
  • 28
  • 47