Java - Applet simply not displaying?

北城以北 提交于 2019-11-28 02:09:55

The applet tag is deprecated and the object tag should be used instead. The applet tag is not supported by some browsers which is probably why you cant see the applet, whereas the object tag should work with pretty much all of them these days.

Edit: Provide code example::

<OBJECT codetype="application/java"
        classid="java:Applet.class"
        width="500" height="500">
My first Java applet.
</OBJECT>

See this link and this link for further examples and information.

As mentioned earlier, it is not recommended to use applet tag. If you are sure that end user browsers will have the JavaScript enabled, you can use this simple way to deploy your applet:

<script src="http://www.java.com/js/deployJava.js"></script>
<script>
    var attributes = {codebase:'http://java.sun.com/products/plugin/1.5.0/demos/jfc/Java2D',
                      code:'java2d.Java2DemoApplet.class',
                      archive:'Java2Demo.jar',
                      width:710, height:540} ;
    var parameters = {fontSize:16} ;
    var version = '1.6' ;
    deployJava.runApplet(attributes, parameters, version);
</script>

The above code will launch the Java 2D applet on JRE version 1.6.0 or higher with one parameter (fontSize).

Just an up-to-date answer for people that searched Google like me (for many things have changed against Java Web Start and Java Applets).

Below cases might be a reason your Java applet web page is not visible:

Chrome no longer supports NPAPI (technology required for Java applets)

The Java plug-in for web browsers relies on the cross platform plugin architecture NPAPI, which has been supported by all major web browsers for over a decade. Google's Chrome version 45 (scheduled for release in September 2015) drops support for NPAPI, impacting plugins for Silverlight, Java, Facebook Video and other similar NPAPI based plugins. https://www.java.com/en/download/faq/chrome.xml

Firefox limits NPAPI support (technology required for Java applets)

The 64-bit version of Firefox does not support NPAPI plug-ins, including Java. Beginning with Firefox 52 (released March 2017), plug-in support is limited to Adobe Flash, and drops support for NPAPI, impacting plugins for Java, Silverlight, and other similar NPAPI based plugins. https://java.com/en/download/help/firefox_java.xml

It looks like Internet Explorer is the best bet as of now.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!