简体   繁体   English

如何修复Applet在Eclipse中工作,但不能在任何浏览器中工作

[英]How to fix applet working in eclipse but not in any browser

I want to use java applet in dynamic web project but it's not working. 我想在动态Web项目中使用Java Applet,但无法正常工作。 I created small applet: 我创建了一个小程序:

`public class MyApplet extends JApplet {
    static final long serialVersionUID = 1L;
    private JTextField textField;`

    /**
     * Create the applet.
     */
    public MyApplet() {
        getContentPane().setLayout(null);

        JLabel lblTag = new JLabel("Tag:");
        lblTag.setBounds(91, 51, 46, 14);
        getContentPane().add(lblTag);

        textField = new JTextField();
        textField.setBounds(126, 48, 86, 20);
        getContentPane().add(textField);
        textField.setColumns(10);

    }

}`

Then i putted it to .JAR file 然后我把它放到.JAR文件中

Next i created Dynamic Web Project and allocate .JAR file in folder in which index.html file is. 接下来,我创建了Dynamic Web Project,并在index.html文件所在的文件夹中分配了.JAR文件。

I put also 我也放

`<applet code="MyApplet.class" archive="name.jar"   width="500" height="500" ></applet>`

to index.html file. 到index.html文件。

When i open this project on apache server i can see html file propertly with styles but aplet is not showing. 当我在apache服务器上打开此项目时,我可以正确看到带有样式的html文件,但aplet没有显示。 It happend in every browser. 它发生在每个浏览器中。 I have not any error in console: 我在控制台中没有任何错误:

`sty 20, 2019 9:13:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version:        Apache Tomcat/8.5.37
sty 20, 2019 9:13:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:          Dec 12 2018 12:07:02 UTC
sty 20, 2019 9:13:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number:         8.5.37.0
sty 20, 2019 9:13:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:               Windows 10
sty 20, 2019 9:13:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:            10.0
sty 20, 2019 9:13:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:          amd64
sty 20, 2019 9:13:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home:             C:\Program Files\Java\jre1.8.0_121
sty 20, 2019 9:13:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:           1.8.0_121-b13
sty 20, 2019 9:13:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:            Oracle Corporation
sty 20, 2019 9:13:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE:         C:\Users\Admin\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1
sty 20, 2019 9:13:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME:         C:\Users\Admin\Desktop\Projekty PWJJ\apache-tomcat-8.5.37\apache-tomcat-8.5.37
sty 20, 2019 9:13:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=C:\Users\Admin\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1
sty 20, 2019 9:13:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=C:\Users\Admin\Desktop\Projekty PWJJ\apache-tomcat-8.5.37\apache-tomcat-8.5.37
sty 20, 2019 9:13:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=C:\Users\Admin\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps
sty 20, 2019 9:13:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=C:\Users\Admin\Desktop\Projekty PWJJ\apache-tomcat-8.5.37\apache-tomcat-8.5.37\endorsed
sty 20, 2019 9:13:47 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1250
sty 20, 2019 9:13:47 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jre1.8.0_121\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.8.0_121/bin/server;C:/Program Files/Java/jre1.8.0_121/bin;C:/Program Files/Java/jre1.8.0_121/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Skype\Phone\;C:\MinGW\bin;C:\WINDOWS\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\PuTTY\;C:\Program Files\Git\cmd;C:\Users\Admin\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\Nmap;C:\Users\Admin\AppData\Local\GitHubDesktop\bin;C:\WINDOWS\system32;;.]
sty 20, 2019 9:13:47 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
sty 20, 2019 9:13:47 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
sty 20, 2019 9:13:47 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
sty 20, 2019 9:13:47 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
sty 20, 2019 9:13:47 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 608 ms
sty 20, 2019 9:13:47 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Catalina]
sty 20, 2019 9:13:47 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.5.37
sty 20, 2019 9:13:48 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
sty 20, 2019 9:13:48 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
sty 20, 2019 9:13:48 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 274 ms`

This will not work with modern browsers. 这不适用于现代浏览器。 Java plugins allowing to run Applets are obsolete for quite some time now eg Firefox did this in 2016 : 允许运行Applet的Java插件在相当长的一段时间内已经过时,例如Firefox在2016年做到了

Websites and publishers which currently use plugins such as Silverlight or Java should accelerate their transition to Web technologies. 当前使用诸如Silverlight或Java之类的插件的网站和发布者应加快向Web技术的过渡。 The Web platform is powerful and can usually do everything that a plugin can do. Web平台功能强大,通常可以执行插件可以执行的所有操作。 In the rare cases where a site needs to extend Web technologies, the recommended solution is to develop the additional features as a Firefox add-on. 在极少数站点需要扩展Web技术的情况下,推荐的解决方案是将其他功能开发为Firefox附加组件。 Site maintainers should prepare for plugins to stop working in all versions of Firefox by the end of 2016. 网站维护人员应为插件做好准备,以在2016年底之前停止在所有版本的Firefox中使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM