我对 Java 是个菜鸟,但我想尝试一下 htmlunit。我使用 netbeans 作为 IDE,并创建了一个项目文件夹“hu1”。下面是该文件夹的结构:
hu1
> nbproject
> src
> hu1
> test
现在,我下载 htmlunit 2.7 并解压缩该文件夹,其中包含一个“lib”文件夹,其中包含一堆 jar 文件。我应该将该 lib 文件夹放在 netbeans 项目文件夹中的什么位置以便我可以使用 htmlunit?
另外,一旦我弄清楚了,我应该使用哪些路径进行导入。我在网上看到的很多例子都使用这样的内容:
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.Page;
com.gargoylesoftware 来自哪里?
我知道这是一个初学者问题,我真的应该更多地阅读如何使用 java 编程,但我会感谢这里专家的一些建议。
更新:这是我的设置的图片。
I'm a pretty big noob to Java, but I would like try out htmlunit. I'm using netbeans as my IDE and I've created a project folder "hu1". Here is the structure for that folder:
hu1
> nbproject
> src
> hu1
> test
Now, I download htmlunit 2.7 and unzipped the folder, which contains a "lib" folder with a bunch of jar files in it. Where do I put that lib folder in my netbeans project folder so that I can use htmlunit?
Also, once I have figured that out, what paths do I use for my imports. A lot of examples I've seen on the web use something like this:
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.Page;
Where do the the com.gargoylesoftware come from?
I know this is a beginner questions, and I really should just read up on how to program with java more, but I would appreciate some advice from the experts here.
UPDATE: Here is a picture of my setup.
发布评论
评论(2)
首先,在 IDE 中注册库。
(来源:netbeans.org)
然后,将库添加到您正在处理的项目中。
(来源:netbeans.org)
您必须从库中添加(更准确地说,从 htmlunit jars 中添加)。
First, register the libraries in the IDE.
(source: netbeans.org)
Then, add the libraries to the project you are working on.
(source: netbeans.org)
From the library you have to add (more precisely, from the htmlunit jars).
com.gargoylesoftware.htmlunit
是您下载的 jar 文件之一中的包。您必须确保这些 jar 文件位于“类路径”上,以便 Java 找到其中的类(Page、BrowserVersion++)。如果您使用 Netbeans,将 jar 文件转储到 lib 文件夹中通常就可以解决问题。
com.gargoylesoftware.htmlunit
Is a package in one of the jar files you've downloaded. You have to make sure that these jar files are on the "classpath" in order for Java to find the classes inside (Page, BrowserVersion++). If you're using Netbeans dumping the jar's in the lib folder will usually do the trick.