这取自:Embedding Java Applet into .html file 已接受回答.Hello I have tried the following code index.jsp<applet code="com.applet.PrintApplet" codebase ="TestApplet.jar" width="320" height="120"></applet>java class PrintApplet.javaimport java.applet.Applet;import java.awt.Color;public class PrintApplet extends Applet{ public void paint(Graphics g){ g.drawString("Welcome in Java Applet.",40,20); }}when this application runs in browser then class not found exception is fired..but i have problem in browser error like a popup box with three button Detail Ignore and ReloadApplication errorclassNotFoundException com.applet.printAppletin Detail buttonJava Plug-in 10.21.2.11Using JRE version 1.7.0_21-b11 Java HotSpot(TM) Client VMUser home directory = C:\Users\Helthcare2----------------------------------------------------c: clear console windowf: finalize objects on finalization queueg: garbage collecth: display this help messagel: dump classloader listm: print memory usageo: trigger loggingq: hide consoler: reload policy configurations: dump system and deployment propertiest: dump thread listv: dump thread stackx: clear classloader cache0-5: set trace level to <n>----------------------------------------------------and i have added jar file in build path also. 解决方案 You have two options:1. to use appletviewer which comes with your JDK to just see the applet work in a bare-bones browser2. embed the applet tag in your HTML page. <html> <title>My Applet</title> <body> <applet code="PrintApplet.class" width="400" height="400"></applet> </body></html> But as it stands, <applet> has been deprecated.So, here is what you do:1. Add this to your <head> : <script src="http://java.com/js/deployJava.js"></script>2. Add this to your <body>: <script> var attributes = {codebase:'http://my.url/my/path/to/codebase', code:'my.main.Applet.class', archive: 'my-archive.jar', width: '800', height: '600'}; var parameters = {java_arguments: '-Xmx256m'}; // customize per your needs var version = '1.5' ; // JDK version deployJava.runApplet(attributes, parameters, version);</script> Again, as of HTML5, <head> is not needed so you can just type <script>....</script>This was taken from: Embedding Java Applet into .html file accepted answer. 这篇关于如何使用web项目在eclipse中运行applet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-28 02:10