试图导入在JAR中找到的类

时间:2022-08-02 22:44:13

I have built a simple project called LibTest that has one class with the following code:

我已经构建了一个名为LibTest的简单项目,它有一个具有以下代码的类:

    public class MainTest
    {
        public static tclass l;
    }

In secondary simple project I have the defined class tclass:

在二级简单项目中,我有定义的类tclass:

    public class tclass
    {
        int i;
    }

Then I export tclass to a JAR file. At LibTest->Properties->BuildPath I click on AddExternalJar and select tclass.jar ( I also tried checking the JAR at Order and Export) but I still get an error at MainTest "tclass cannot be resolved to a type".

然后我将tclass导出到JAR文件。在LibTest-> Properties-> BuildPath中,我单击AddExternalJar并选择tclass.jar(我也尝试在Order和Export中检查JAR)但是我仍然在MainTest上遇到错误“tclass无法解析为类型”。

I don't see what is missing.

我看不出有什么遗漏。

Thanks Simon

1 个解决方案

#1


0  

After including your jar file, you also need to import your class using its full path in your MainTest class. e.g:

包含jar文件后,还需要使用MainTest类中的完整路径导入类。例如:

import com.package.tclass;

#1


0  

After including your jar file, you also need to import your class using its full path in your MainTest class. e.g:

包含jar文件后,还需要使用MainTest类中的完整路径导入类。例如:

import com.package.tclass;