简体   繁体   中英

java applet class not found exception in the chrome browser

I am trying to run Java applet using Google Chrome browser . Everytime I am getting no class found exception . Here is my code.

HelloWorld.java

package my.first.pack;

import java.applet.Applet;
import java.awt.*;

public class HelloWorld extends Applet {

    /**
     * 
     */
    private static final long serialVersionUID = 2741715258812838900L;

    public void paint(Graphics g) {
        g.drawString("welcome", 150, 150);
    }

}

Hello.html

<applet code="my.first.pack.HelloWorld" width="300" height="300">  
  1. Sign your applet and all the .jar dependencies with a certificate.
  2. Populate your manifest with all the tags mentioned below (it's in xml because I use maven, you can write in the way you prefer)
<codebase>http://location.of.your.jar/</codebase>
<permissions>all-permissions</permissions>
<Application-Library-Allowable-Codebase>http://location.of.your.jar/</Application-Library-Allowable-Codebase>
<Manifest-Version>1.0</Manifest-Version>
<Implementation-Title>App Name</Implementation-Title>
<Implementation-Version>0.1.0</Implementation-Version>
<Application-Name></Application-Name>
<Created-By>1.8.0_45</Created-By>
<Main-Class>package.YourClass</Main-Class>
<mode>development (or production)</mode>
<url>url of the application</url>
  1. Surround your java method with the doPrivileged
  2. Be sure that your browser has the java plugin enabled
  3. Put your http path of your web app in the java exception list
  4. If your url has _ (underscore/underline) probably it won't be recognized.
  5. Try to move your .jar to the same folder of your html, not using the /applet folder.
  6. Take a look on this post , I was having a similar issue.

Remember, this error saying that 'is not a function' is because your .jar is not loading - or you made something wrong with the js syntax, what I don't think so.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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