在 Netbeans Web 应用程序中使用小程序 [英] Use applet in Netbeans web application

查看:32
本文介绍了在 Netbeans Web 应用程序中使用小程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<applet archive='AlienWar.jar' code='AlienWarApplet.class' width='387' height='410'>
                                </applet>

我有一个小程序,当我在 html 中使用它并将 .jar 放在同一目录中时,它工作得很好.但是现在我正在 netbeans 中构建一个 Web 应用程序(我使用 JSF 框架和 Apache Tomcat 服务器).我在 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 需要位于服务器上的某个位置,如果您在浏览器地址栏中输入地址并按 Enter,您可以从中获取它

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

对于网络应用程序,这尤其意味着.不要将存档放在您可能用于 servlet/JSP 库的 WEB-INF/lib 目录中.该目录不提供给最终用户浏览.

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.

可以通过将存档放在与 HTML 相同的目录中来使代码工作(假设 HTML 位于通过获取测试"的位置),但这是草率的,可能会导致相同的 Jar在许多小程序的许多目录中.

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",JRE 将在 http://archive 属性中逗号分隔列表中任何存档的 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆