3

Apparently Scala on Eclipse tries to convince me that DateTime, Period, DateMidnight and many other classes in Joda Time don't have any constructors

Which is odd considering the fact that the documentation for them shows a constructor and a number of methods

The only things I have access to are the static methods such as DateTime.now() and DateTime.parse()

Note that I have added the joda-time-2.2.jar, joda-time-2.2-sources.jar, and joda-time-2.2-javadoc.jar files to the java build path of the project...

and yet whenever I try to make an instance of say DateTime Eclipse will tell me org.joda.time.DateTime does not have a constructor

So anyone got any idea why I get this error? And more importantly, how do I fix it?

om-nom-nom
  • 62,329
  • 13
  • 183
  • 228
Electric Coffee
  • 11,733
  • 9
  • 70
  • 131

1 Answers1

6

It seems you need to add joda-convert to your classpath. Answer taken from here.

If you're not using Maven or Sbt, you can manually download the jar from its Maven Central page. All you need to do is add it to your project build path.

Iulian Dragos
  • 5,692
  • 23
  • 31
  • also the answer you gave me specifies that I should get the Joda Convert jar file... which according to the documentation is used to convert objects to classes and back... how would that help me in any way? – Electric Coffee May 23 '13 at 19:38
  • try what? I don't even know what to do, it doesn't give any code examples all it says is to add the joda-convert library, it doesn't tell me how to use it or anything... – Electric Coffee May 23 '13 at 19:53
  • 1
    Well, just add it to your classpath! If you had read the linked article, you'd have seen that the Scala compiler expects to find all referenced class on the classpath, and one (or more) from joda-convert are missing. – Jean-Philippe Pellet May 23 '13 at 19:56
  • I wonder why joda-convert isn't just in the joda-time zip from the get-go, that would have saved so much pain... but yeah thanks this wored – Electric Coffee May 23 '13 at 20:02
  • 2
    Just as a heads up. You should generally trust @Iulian Dragos when it comes to compiler related issues. He probably wrote the scala compiler you are using :) – cmbaxter May 23 '13 at 20:05
  • @cmbaxter, thank you but I can't take that much credit. I contributed to many parts, especially backend, but there are a lot of people who worked on scalac. ElectricCoffee, no problem, the error messge *is* wrong and confusing. I assumed you're using some dependency manager already. – Iulian Dragos May 23 '13 at 20:13
  • @IulianDragos I'm not using any dependency managers... I'm just coding in barebones Eclipse with the Scala IDE nothing fancy – Electric Coffee May 23 '13 at 20:16