Skip to content
Advertisement

Can we call another project java class from our project in eclipse

import ...

public class TriggerJob {
    
    String jobStatus = "";
    SchedulerMetaData metaData = null;
    
    public void rightNow(HashMap ParamMap) {
        AnotherProjectClass anp = new AnotherProjectClass();
        anp.display();
    }

}

Advertisement

Answer

You can do either this way:

In the dependency you can add the other projects to your project. Right click on project -> properties -> java build path -> projects. Add your project here.

OR

Make the classes of project into jar and add it to other project

Dependencies should be added in classpath

In run time, make sure the JAR files of the referenced projects is added in class path on both the cases.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement