简体   繁体   中英

Add a project with a static class to another project in Eclipse

OK, this might be a pretty basic question so please sorry.

In Eclipse, I have a project with some utilities, let's call it Utils. Something like

public class Utils {
   public static void doSomething() {
        // do something
   }
}

I want to use this project as a library for many my other projects, for example my project "MyProject"

After I assure that there are no syntax problems in Utils, I keep it open in the UI and open also MyProject.

In MyProject I go to Properties -> Java Build Path -> Projects -> Add and add Utils. Now I should be able to see Utils.doSomething() when I press CTRL-Space and use it in the code, but this is not the case. What am I missing? I have been going round and round to find how but could not find a solution.

Thank you very much

EDIT: I think I tried all the usual problem-solving solutions like cleaning the projects, restarting Eclipse, recreating ex-novo Utils, rebuilding and automatic imports. For this reason I think that the real problem is not Eclipse but me, I am missing something that I don't understand.

I think I solved it. The Utils (Android) project had the public class in the "default container" that had no name, probably that was the reason.

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