如何将Java类库导入Java Web项目(使用NetBeans)? [英] How do you import a Java Class Library into a Java Web project (using NetBeans)?
问题描述
我已经尝试了添加文件夹...",添加库..."和添加JAR/文件夹..."选项,但是这次不起作用-我已经做到了之前几次没有任何问题.
I've already tried the options "Add folder...", "Add Library...", and "Add JAR/Folder...", but it's not working this time -- I've done this several times before without any problems.
我还尝试过以各种可行的方式将文件夹/JAR文件(.war-file)手动添加到项目属性中,但仍然没有成功.
I've also tried to add the folder / JAR file (.war-file) manually to the projects properties in every thinkable way, but still no success.
到目前为止,谷歌也没有提供帮助.
And so far, Google hasn't helped either..
我们将不胜感激.
(这是针对使用NetBeans 7.1的JavaServer Faces的Java Web项目)
(This is for a Java Web project with JavaServer Faces, using NetBeans 7.1)
已解决:我从未发现是什么原因导致了问题.最后,我重新安装了整个NetBeans,并重新创建(尝试了一千次)要导入的项目.最后,我让它工作了.
Solved: I never found out what caused the problem. I ended up re-installing entire NetBeans, and re-created (a thousand times) the project I was trying to import. And in the end, I got it working.
推荐答案
将JAR文件放入Web项目的WEB-INF/lib目录中. WEB-INF/lib中的所有JAR和WEB-INF/classs中的所有软件包都自动在CLASSPATH中.
Put the JAR file in the WEB-INF/lib directory of your web project. All JARs in the WEB-INF/lib and all packages in WEB-INF/classes are automatically in the CLASSPATH.
您可以使"Hello,servlet"工作吗?如果没有,为什么还要打扰JSF?成功创建一个简单的Web应用程序并从那里开始构建.
Can you make "Hello, servlet" work? If not, why bother with JSF? Do a simple web app successfully and build up from there.
这篇关于如何将Java类库导入Java Web项目(使用NetBeans)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!