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

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

问题描述

因此,我在Java中具有以下代码,该代码将applet部署到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+"\">');");

此处包含代码库和代码的地方:

Where codebase and code are taken here :

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文件启动任何可在浏览器中运行的小程序, 您使用applet标签.有关更多信息,请参见Java Applets. 课.如果小程序捆绑为JAR文件,那么您唯一要做的就是 需要做的不同是使用archive参数指定 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天全站免登陆