直接从jar文件中启动Java小程序 [英] Starting Java applet directly from jar file

查看:161
本文介绍了直接从jar文件中启动Java小程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的目标是有一个从jar文件的小程序的运行。

The goal is to have an applet run from a jar file.

问题是,小程序似乎只是想从一个爆炸的jar文件运行。

The problem is that the applet only seems to want to run from an exploded jar file.

在互联网上的样品表明此applet标记:

Samples on the Internet suggest this applet tag:

  <applet code="com.blabla.MainApplet"
          archive="applet.jar"
          width="600" height="600">

这甚至不会尝试在jar文件的外观和失败:

This will not even try to look in the jar file and fails with:

Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8080/helloWord/com/blabbla/MainApplet.class
 at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
 at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
 at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
 at java.security.AccessController.doPrivileged(Native Method)
 ... 7 more

设置codeBase的,而不是存档属性的jar文件。看起来好一点。但是,JVM没有意识到,它必须打开jar文件:

Setting the codebase instead of the archive attribute to the jar file. Looks a bit better. However, the JVM does not realize that it has to open the jar file:

  <applet code="com.blabla.MainApplet"
          codebase="applet.jar"
          width="600" height="600">


Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8080/helloWord/applet.jar/com/blabbla/MainApplet.class
 at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
 at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
 at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
 at java.security.AccessController.doPrivileged(Native Method)
 ... 7 more

如何applet标记都需要制定从的启动一个小程序类的内部的一个jar文件?

推荐答案

的问题是,Java控制台被缓存previous坏的罐子。一旦缓存在Java控制台清零,code的第一个版本的罚款。

The problem was that the Java console was caching previous bad jars. Once the cache was cleared in the Java console, the first version of the code worked fine.

<applet code="com.blabla.MainApplet"
          archive="applet.jar"
          width="600" height="600">

这篇关于直接从jar文件中启动Java小程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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