run applet in web application

后端 未结 3 560
悲&欢浪女
悲&欢浪女 2020-12-10 06:29

I want to run simple applet in my web application using html applet tag but it gives error like

java.lang.ClassNotFoundException: MyApplet

please, give me

3条回答
  •  难免孤独
    2020-12-10 07:02

    the problem is that the applet engine can't find your MyApplet class at the codebase you have defined.

    This can be caused because you have you class at your /WEB-INF/classes directory. This directory is protected by the servlet engine, for it not to be accesed from external resources (as can be an applet tag at a JSP/HTML page.

    There are a few ways to solve this. The easiest one is to pack your MyApplet class un a jar file (let's call it myapplet.jar), and save it at an accesible directory (i.e. the jsp folder of your web application). As an example, supose you have the following folders for the web application:

    /MyWebApp/jsp
    /MyWebApp/applet
    /MyWebApp/WEB-INF
    

    The client browsers can access the content of jsp and applet folders.

    Then, save your myapplet.jar at the applet folder, and set your applet tag configuration like this (suposing that you web context is MyWebApp):

    
    
    

    Here you can find more info about the applet tag: http://docs.oracle.com/javase/tutorial/deployment/applet/index.html

提交回复
热议问题