error: expected class or object definition
Asked Answered
S

1

29

I have this (smart code):

import com.mongodb.casbah.Imports._
import com.mongodb.casbah.util.bson.conversions._
RegisterJodaTimeConversionHelpers() //error

object Main {
  def main(args: Array[String]) {
    val connection = MongoConnection()
  }
}

I get an error:

error: expected class or object definition
RegisterJodaTimeConversionHelpers()

I have to use this RegisterJodaTimeConversionHelpers() (2.2. Briefly: Automatic Type Conversions), but there's always this error message. Any ideas?

Savoyard answered 1/11, 2011 at 10:16 Comment(0)
A
39

You have to write this line of code somewhere it can be executed. How about in your main method instead?

object Main {
  def main(args: Array[String]) {
    RegisterJodaTimeConversionHelpers()
    val connection = MongoConnection()
  }
}
Articulator answered 1/11, 2011 at 10:48 Comment(2)
Hi. No this is not helping. If I copy that in the Main ill get the error: class file needed by ValidDateOrNumericTypeHolder is missing. because there JodaTime wasnt registred.Savoyard
It is not "because there JodaTime wasnt registred", it is because you are missing some dependencies on your classpath.Articulator

© 2022 - 2024 — McMap. All rights reserved.