简体   繁体   English

在“ Java构建路径” Eclipse中的“添加类文件夹”之后,无法在“参考库”中导入类

[英]Unable to import a class in “Referenced libraries” after “Add Class Folder” in “Java Build Path” Eclipse

I'm trying to include package X in project B as reference in my project A. Both project A and B are in my same workspace. 我试图将包X包含在项目B中,作为我的项目A中的引用。项目A和B都在同一个工作区中。 Both A and B are Android/ Java projects. A和B都是Android / Java项目。

I click on " Add Class Folder " in " Java Build Path " in Eclipse and choose package X folder and now it appears under " Referenced libraries " in my project A: 我在Eclipse的“ Java构建路径 ”中单击“ 添加类文件夹 ”,然后选择包X文件夹,现在它出现在我的项目A中的“ 引用的库 ”下:
在此处输入图片说明

Reference Libaries
   src/[path-to-package-X]

Now I'm not able to import a class in that folder. 现在,我无法在该文件夹中导入一个类。 Eclipse is not making any suggestion either. Eclipse也没有提出任何建议。

import sg.xxx.xxx.xxx.ABaseClass;//sg.xxx.xxx.xxx is the package X  
==> The import "sg" cannot be resolved

Why doesn't it work? 为什么不起作用? What am I doing wrong here? 我在这里做错了什么?

*Notes: *笔记:
Project B is huge so I only want to include package X but not anything else. 项目B很大,所以我只想包含软件包X,而没有其他任何东西。

It's much better to add the project as a "referenced" project in {project} / right-click / Properties / Java Build Path / Projects / Add. 最好在{project} /右键单击/ Properties / Java Build Path / Projects / Add中将项目添加为“引用”项目。

Another alternative is to keep producing .jar s and add them as libraries. 另一种选择是继续产生.jar并将其添加为库。 Useful is this part of the code is stable enough. 有用的是这部分代码足够稳定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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