在Netbeans的Web应用程序使用小程序 [英] Use applet in Netbeans web application
问题描述
<applet archive='AlienWar.jar' code='AlienWarApplet.class' width='387' height='410'>
</applet>
我有一个小程序和它的作品就好了,当我在HTML中使用它,并在同一目录下的.jar。但现在我建立在NetBeans(我用JSF框架和Apache Tomcat服务器)的Web应用程序。我插入相同code中的index.xhtml和添加的.jar编译时库,但我得到一个classNotFoundExeception。
I have an applet and its works just fine when I use it in html and have the .jar in the same directory. But now I am building a web application in netbeans(I use JSF framework and Apache Tomcat server). I insert the same code in the index.xhtml and add the .jar to compile time libraries, but i get a classNotFoundExeception.
在哪里我应该把该.jar ??
Where should I put the .jar??
推荐答案
的JAR需要在服务器上的一个地方,你可以从你在浏览器地址栏中输入的地址把它拿来和命中<大骨节病>输入骨节病>
The Jar needs to be in a place on the server where you could fetch it from if you typed the address in the browser address bar and hit Enter
对于Web应用程序,这意味着特别。 不要把档案中的 WEB-INF / lib目录
你可能使用的servlet / JSP库目录。该目录是不提供给浏览最终用户。
For a web app., that particularly means. Do not put the archive in the WEB-INF/lib
directory you might use for servlet/JSP libraries. That directory is not offered to the end user for browsing.
在code可以使通过将归档文件在同一目录作为HTML(presuming的HTML是在传递'获取测试的位置)的工作,但是这是草率和可能导致许多小程序许多目录相同的瓶子之中。
The code can be made to work by putting the archive in the same directory as the HTML (presuming the HTML is in a location that passes the 'fetch test'), but that is sloppy and might lead to the same Jar being in many directories for many applets.
相反,我通常把所有的小程序档案单一目录在域的根。特别是(在这里没有硬性规定) LIB
。指定 codeBase类=/ lib目录
在applet元素和JRE会看在的 http://your.com/lib 不管什么档案是在归档
属性的逗号分隔的列表的路径。
Instead I would typically put all the applet archives in a single directory at the root of the domain. Specifically (no hard and fast rules here) lib
. Specify codebase="/lib"
in the applet element and the JRE will look in the http://your.com/lib path for whatever archives are in the comma separated list in the archive
attribute.
这篇关于在Netbeans的Web应用程序使用小程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!