[英]How to Import Classes from Reference Library in Eclipse?
I am new to both Java and to the Eclipse IDE, and I am having trouble with adding a Referenced Library and actually using it in my code. 我是Java和Eclipse IDE的新手,在添加引用库并在我的代码中实际使用它时遇到了麻烦。
I am in a software testing class, and my assignment is to use the JWebUnit library to run some basic tests on a website of my choice. 我正在参加软件测试课程,我的任务是使用JWebUnit库在我选择的网站上运行一些基本测试。 I have downloaded a zip of the library and added it to the build path, so that it shows up in my Referenced Libraries list.
我已经下载了该库的一个zip并将其添加到构建路径,以便它显示在我的“参考库”列表中。
When I try to actually use that library, though, the import statement gives an error. 但是,当我尝试实际使用该库时,import语句给出了一个错误。
I just cannot figure out what I am doing wrong that the base class cannot see this library. 我只是无法弄清楚我在做什么,基类看不到该库。
The screenshot show that you have added the folder net
as class folder to the Java Build Path . 屏幕快照显示您已经将文件夹
net
作为类文件夹添加到Java Build Path 。 Maybe you have added the source code ( .java
files) or Javadoc ( .html
files) instead of the executable bytecode ( .class
files). 也许您添加了源代码 (
.java
文件) 或Javadoc ( .html
文件), 而不是可执行字节码 ( .class
文件)。 Usually .jar
files are provided containing .class
files which can directly be added to the Java Build Path . 通常提供的
.jar
文件包含.class
文件,这些文件可以直接添加到Java Build Path中 。
Probably you want to download eg the file jwebunit-3.3-release.zip
from here and add all JARs contained in that ZIP (in the root folder and in lib
) to your Java Build Path instead. 可能您想从此处 下载例如
jwebunit-3.3-release.zip
文件, 并将该ZIP中包含的所有JAR (位于根文件夹和lib
)添加到Java Build Path中 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.