Search code examples
javaprojects

Java - How do i call a class from a different project?


This is my Main class, im trying to call both the ScheduleData and ScheduleTime classes from a different project.

public main(String[] args) {
    ScheduleDate sd = new ScheduleDate();
    ScheduleTime st = new ScheduleTime();
    int testMonth = 2;
    int testDay = 2;
    int testYear = 2016;
    int testHour = 5;
    int testMinute = 30;
    String testPeriod = "PM";
    sd.setMonth(testMonth);
    sd.setDay(testDay);
    sd.setYear(testYear);
    st.setHour(testHour);
    st.setMinute(testMinute);
    st.setPeriod(testPeriod)

Solution

  • You need to add project B to the Run configuration used by project A. In the menu Run -> Run configurations... , add the project B in the tab 'classpath' of your run configuration.

    see here calling a class in another project Eclipse