Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9276423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:50:59+00:00 2026-06-18T16:50:59+00:00

I created a simple project. sbt run works fine. After I run sbt package

  • 0

I created a simple project.

“sbt run” works fine.

After I run “sbt package” jar file appears, but it does not work.

$ scala target/scala-2.9.2/hello_2.9.2-0.1.jar

The following error occures:

java.lang.NoClassDefFoundError: com/mongodb/DBObject

Here are my files:

Hello.scala

package greeter
object Hello extends App {
    import com.mongodb.casbah.Imports._
    val mongoClient =  MongoClient()
    println("Connected to MongoDB")
    val collection = mongoClient("test")("foo")
    val doc = MongoDBObject("msg" -> "Hi from Scala!")
    collection.insert(doc)
    println("Doc inserted");
}

build.sbt

name := "hello"

mainClass := Some("greeter.Hello")

version := "0.1"

scalaVersion := "2.9.2"

libraryDependencies += "org.mongodb" % "casbah_2.9.2" % "2.5.0"

resolvers += "snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"

resolvers += "releases"  at "https://oss.sonatype.org/content/groups/scala-tools"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T16:51:01+00:00Added an answer on June 18, 2026 at 4:51 pm

    You need to add the library dependencies to your classpath when running the scala command. Assuming you download all the libraries jars in a lib folder, you will need to run:

    scala -cp "lib/*" target/scala-2.9.2/hello_2.9.2-0.1.jar
    

    In build.sbt, use the following setting to automatically download all the jars in a lib_managed folder:

    retrieveManaged := true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i created a simple project with zf and it works fine, but when i
I created a simple Java EE project in NetBeans (File -> New Project ->
It's not a very concrete question. I created a simple project with a help
I created a simple Maven project (Packaging type - Jar) that has dependencies on
I created one simple demo project, which does the animation using AnimationDrawable class of
I'm trying to run a simple project. I'm struggling with some issues. I created
I've created a simple Java project (not a Dynamic Web Project) in Eclipse. I'd
I've created a simple Project model with four attributes: Project name:string description:text complete:boolean user_id:integer
I just created a simple project in VS2010, C# dotnet 3.5 using System; using
We have created a simple wix project for a basic windows application. Everything builds

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.