[英]Error Event when trying to open applet on a browser
I have done a few Java programs but this is the first one that I'm trying to run as an applet so I might have some basic error. 我已经完成了一些Java程序,但这是我第一个尝试作为applet运行的程序,所以我可能会遇到一些基本错误。
I compiled all the classes and put them together in a jar file called final. 我编译了所有类并将它们放在一个名为final的jar文件中。 I followed a few tutorials to make a JNLP file that I called jnlp (yeah, I know, I'm very original:) and on which I called to my jar file and I called the JNLP file from an HTML file.
我按照一些教程制作了一个JNLP文件,我称之为jnlp(是的,我知道,我非常原创:)并且我调用了我的jar文件并从HTML文件中调用了JNLP文件。
Those are the last lines of the java console output: (before them, the console is filled with my JNLP file) 这些是java控制台输出的最后几行:(在它们之前,控制台充满了我的JNLP文件)
at sun.plugin2.applet.JNLP2Manager.loadJarFiles(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
preloader: Added pending event 2: ErrorEvent[url=null label=JNLP not an applet, nor a JavaFX application cause=JNLP not an applet, nor a JavaFX application
Here is the JNLP file: 这是JNLP文件:
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="" href="jnlp.jnlp">
<information>
<title>Encryption Software</title>
<vendor>Atlantis Atlantis</vendor>
<icon href="encrypt_logo.jpg"/>
<offline-allowed/>
</information>
<resources>
<!-- Application Resources -->
<j2se version="1.6+" href=
"http://java.sun.com/products/autodl/j2se"/>
<jar href="final.jar"
main="true" />
</resources>
<application-desc
name="Encryption Software"
main-class="EncryptApplication"
width="500"
height="300">
</application-desc>
<update check="background"/>
</jnlp>
Here is the JS used to launch the applet: 这是用于启动applet的JS:
<script src="https://www.java.com/js/deployJava.js"></script>
<script>
var attributes = {code:'', width:500, height:500};
var parameters = {jnlp_href: 'jnlp.jnlp'};
deployJava.runApplet(attributes, parameters, '1.6');
</script>
Is the EncryptionApplication
really an applet? EncryptionApplication
真的是一个applet吗? To be an applet it must extend Applet
or JApplet
. 要成为applet,它必须扩展
Applet
或JApplet
。
If it is not an applet, it cannot be embedded in HTML. 如果它不是applet,则无法嵌入HTML中。
If it is an applet, the JNLP must declare it as such, so: 如果它是 applet,JNLP必须声明它,因此:
<application-desc
name="Encryption Software"
main-class="EncryptApplication"
width="500"
height="300">
</application-desc>
Should be: 应该:
<applet-desc
name="Encryption Software"
main-class="EncryptApplication"
width="500"
height="300">
</applet-desc>
JFrame
based app.) from a link using Java Web Start . JFrame
的应用程序)。 They will be subject to the same (very strict) security requirements of applets, but have none of the applet specific problems (see link in previous point for details). code
attribute. code
属性的有效值。 There are circumstances in which it can be left out, but I won't get into that right now..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.