Making an Applet in Mac Lion.
Hi there! This is my first question, and the reason I made an account really, so don't laugh. I've been stuck on this problem the past three days and I haven't made any real progress with it. All that I am trying to do is make an applet where I can see a red box, that's it. Here's my code for my Java and HTML files.
JAVA
import javax.swing.JApplet;
import java.awt.*;
public class Fish extends JApplet
{
public void paint(Graphics g)
{
g.setColor( Color.red );
g.drawRect( 0,0,500,500 );
}
}
HTML
<html>
<head>
<title>
k1
</title>
</head>
<body>
<applet code = "Fish.class" width=500 height=500>
</applet>
</body>
</html>
I compiled my Fish.java using the terminal line javac -classpath . Fish.java and both files (actually, all three after I compiled) are on my desktop. However, when I double click k1.html, on any browser, I get an error. I even ran the terminal code /Applications/Utilities/Java\ Preferences.app/Contents/MacOS/Java\ Preferences to make sure my Java was on for my browsers and it was. Can I get some help?!
Thanks! :)
Re: Making an Applet in Mac Lion.
What error? Post it in its entirety
2 Attachment(s)
Re: Making an Applet in Mac Lion.
Quote:
Originally Posted by
doWhile
What error? Post it in its entirety
load: class Fish.class not found.
java.lang.ClassNotFoundException: Fish.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Ap plet2ClassLoader.java:252)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(P lugin2ClassLoader.java:249)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Pl ugin2ClassLoader.java:179)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Pl ugin2ClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 47)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Plu gin2ClassLoader.java:690)
at sun.plugin2.applet.Plugin2Manager.createApplet(Plu gin2Manager.java:3045)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Plugin2Manager.java:1497)
at java.lang.Thread.run(Thread.java:680)
Exception: java.lang.ClassNotFoundException: Fish.class
Desktop:
Attachment 2788
Code:
Attachment 2789
However, k1.html and Fish.class are both on my desktop! I'm sorry for being unclear before, can you give me ny advice? I've been trying to solve this for a while.