I am having trouble with a HelloWorld Applet.
Here is my Java code:
package webCrawler.applet2;
import javax.swing.JApplet;
import java.awt.Graphics;
public class HappyFace extends JApplet
{
public void paint (Graphics canvas)
{
canvas.drawOval(100,50,200,200);
canvas.fillOval(155,100,10,20);
canvas.fillOval(230,100,10,20);
canvas.drawArc(150,160,100,50,0,180);
}
}
Here is my index.html
:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="000000">
<center>
<applet
code = "HappyFace.class"
width = "500"
height = "300"
>
</applet>
</center>
</body>
</html>
In Eclipse if I go: Run -> Run
it works, however if I do this:
% pwd
/Users/me/Documents/workspace/WebCentric/bin/webCrawler/applet2
% ls
HappyFace.class index.html
% open index.html
It opens the html page in Firefox but the app does not work:
Update:
As Pablo Santa Cruz suggested I:
- Changed the location of index.html
- Changed index.html to be
code = "webCrawler.applet2.HappyFace"
This is the exception in the console.
java.lang.UnsupportedClassVersionError: webCrawler/applet2/HappyFace (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:213)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:151)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:680)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:635)
at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1991)
at jep.AppletFramePanel.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:564)
at sun.applet.AppletPanel.run(AppletPanel.java:301)
at jep.AppletFramePanel.run(Unknown Source)
at java.lang.Thread.run(Thread.java:552)