I had an issue a couple of days ago with Java applets. Here is my code:
Hello.java
class file
//Reference the required Java libraries
import java.applet.Applet;
import java.awt.*;
import java.io.*;
//The applet code
public class Hello extends Applet {
public static void main(String[] args) {
//new Main();
System.out.println("Hello worlds");
}
}
And the HTML file applet.html
<HTML>
<HEAD>
<TITLE> My First Java Applet </TITLE>
</HEAD>
<BODY>
<P>Here's my first Java Applet@@@@: <BR><BR><P>
<applet code ="Hello.class" width="200" height ="200"> APPLET </applet>
</BODY>
</HTML>
and I had taken the issue,
"Error,click for details."
and another issue I take when I'm trying to run my applet from command prompt is
C:\Users\Andreas>cd C:\xampp\htdocs\mysite\
C:\xampp\htdocs\mysite>appletviewer applet.html
after I click enter the appletviewer
window is opening but does not displaying anything.It just says: "Applet started"
I Have installed the latest version of java and Java SDK, and I also double-check this in java.com.
I'm running this locally.
Can anyone help me? What I'm missing? In other websites which are running java applets its just asking for permission at the top of the browser and that's all.
I'm trying to get this to work in order to write code about multitasking (any other ideas about multitasking for a website?)
In the Applet class, main() method is not there. Please try to execute the below example:-
-