简体   繁体   中英

How to create my own utility classes in Eclipse?

I'm a student, so please bear with me!

I've got some introductory Java (using BlueJ) but I'm taking a Java course and using Eclipse. I'm working on my homework, and each week's lab builds on the previous week. I'm finding that it would be useful to create a couple of my own utility classes that I can import into my lab projects, rather than having the same classes coded into every project.

I can't figure out how to do this correctly, however. In my project's build path I've used the "link source" function to point to the project folder where my utility class lives, but I still get a message from Eclipse that it can't resolve the import.

Can someone point me in the right direction? I've reviewed the answers to similar questions but no joy.

Thanks, dean

You can create multiple projects in Eclipse. Put your utility classes into one project. Then when you create a new project for an assignment, add the utility project to the "Java Build Path" (right-click the project, choose "Properties".) The assignment classes will then have the utility classes available.

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