Reputation: 586
I am writing a basic Java program using JodaTime to convert a date from the Gregorian Calendar to the Islamic Hijri Calendar. However, when I run my code, I get the following error:
Error: Unable to initialize main class MainActivity Caused by: java.lang.NoClassDefFoundError: org/joda/time/Chronology
Below is my code:
import org.joda.time.Chronology;
import org.joda.time.LocalDate;
import org.joda.time.chrono.IslamicChronology;
import org.joda.time.chrono.ISOChronology;
public class MainActivity {
public static void main(String[] args) {
Chronology iso = ISOChronology.getInstanceUTC();
Chronology hijri = IslamicChronology.getInstanceUTC();
LocalDate todayIso = new LocalDate(2021, 8, 17, iso);
LocalDate todayHijri = new LocalDate(todayIso.toDateTimeAtStartOfDay(),
hijri);
System.out.println(todayHijri);
}
}
This seems strange, considering that I have downloaded the latest joda time jar file from the official Joda Time release history on GitHub: https://github.com/JodaOrg/joda-time/releases (joda-time-2.10.10.jar
), added it to the lib folder in my project, and added the jar file to my build path, as you can see in the file hierarchy below:
Upvotes: 1
Views: 1085
Reputation: 586
As @Abra stated, making sure the JAR file was on my run configuration in my classpath worked :D.
Upvotes: 1