将 .jar 部署到 html 页面 [英] Deploying a .jar into a html page

查看:38
本文介绍了将 .jar 部署到 html 页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在 Java 中有以下代码,它将小程序部署到 html 页面中.

So I have the following code in Java which deploys an applet into a html page.

由于安全问题,我正在尝试将其设为 .jar,然后对该 .jar 进行签名,以首先查看它是如何工作的.

Due to security problems I'm trying to make it a .jar and then sign that .jar to see first how that will work.

不幸的是,鉴于 .jar 中的主类是相同的,我不确定应该更改什么才能将其作为 .jar 运行:

Unfortunately I'm not really sure what I should change in order to run it as a .jar, given that the main class in the .jar is the same:

p.println(document+"<applet name=\"myApp\" codebase="+codebase+" code="+code+ " width='+(scnWid-30)+' height='+(scnHei-45)+'>');");
        p.println(document+"<param name=user value=\""+user+"\">');");
        p.println(document+"<param name=sessionid value=\""+sessionid+"\">');");

代码库和代码在这里:

public void init(ServletConfig config) throws ServletException {
            super.init(config);
            ServletContext context = getServletContext();
            applet_code_base = context.getInitParameter("applet_code_base");
            applet_code = context.getInitParameter("applet_code");

          }

推荐答案

Oracle 网站 这个位置说:

The Oracle website at this location says:

要从 HTML 文件启动任何小程序以在浏览器中运行,你使用小程序标签.有关更多信息,请参阅 Java 小程序课.如果小程序捆绑为 JAR 文件,您唯一需要做的就是需要做的不同是使用存档参数来指定JAR 文件的相对路径.

To start any applet from an HTML file for running inside a browser, you use the applet tag. For more information, see the Java Applets lesson. If the applet is bundled as a JAR file, the only thing you need to do differently is to use the archive parameter to specify the relative path to the JAR file.

它声称

<applet code=TicTacToe.class 
        archive="TicTacToe.jar"
        width="120" height="120">
</applet>

是适当的 html 代码,用于显示在 html 文件所在的同一目录中存储为 TicTacToe.jar 的小程序.

is the appropriate html code to display an applet stored as TicTacToe.jar in the same directory as the html file.

这篇关于将 .jar 部署到 html 页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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