简体   繁体   中英

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)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM