Results 1 to 3 of 3
Thread: Making an Applet in Mac Lion.
- 02-01-2012, 02:34 AM #1
Member
- Join Date
- Feb 2012
- Posts
- 5
- Rep Power
- 0
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! :)
- 02-01-2012, 03:37 AM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,619
- Rep Power
- 5
Re: Making an Applet in Mac Lion.
What error? Post it in its entiretyI get an error.
- 02-01-2012, 05:08 AM #3
Member
- Join Date
- Feb 2012
- Posts
- 5
- Rep Power
- 0
Re: Making an Applet in Mac Lion.
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:

Code:

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.
Similar Threads
-
Java issue on Mac Lion
By vrobic in forum New To JavaReplies: 1Last Post: 11-07-2011, 02:25 PM -
Need help making an applet that displays a pie chart.
By jeskoston in forum New To JavaReplies: 5Last Post: 05-14-2011, 12:33 AM -
Applet making cookies
By mneskovic in forum New To JavaReplies: 18Last Post: 08-31-2010, 04:32 AM -
Making a program out of a Java Applet
By Bomber_Will in forum Java AppletsReplies: 1Last Post: 07-16-2009, 02:54 AM -
Making an Applet use a MySQL Database
By Bomber_Will in forum Java AppletsReplies: 5Last Post: 11-30-2008, 04:28 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks