Reputation: 107
I have a very simple problem. My "Hello World" applet is not transferring into html for some reason.
I am providing the code class and code base to upload the file, but for some reason, the html states that there is an error and the error looks like a bunch of commands from an operating system terminal.
I am using Mac OS and the coding for the Java and HTML are the following:
import java.awt.*;
public class Hello extends javax.swing.JApplet {
String greeting;
public void init() {
FlowLayout flo = new FlowLayout();
setLayout(flo);
greeting = "Hello!";
}
public void paint(Graphics screen) {
Graphics2D screen2D = (Graphics2D) screen;
screen2D.drawString(greeting, 25, 50);
}
}
I have the HTML set up properly with the tags, head, title, and body. The applet is in the body and is coded as the following:
applet width="400" height="200" codebase="..\\..\\build\\classes" code="Hello.class"
Any help is much appreciated.
Upvotes: 1
Views: 2574
Reputation: 13079
Create an html file in the directory where Hello.class is, containing this:
<applet width="400" height="200" codebase="." code="Hello.class">
Open it with your browser, and if your Java plugin is configured correctly you should see the applet. It works for me:
Upvotes: 1