Results 1 to 17 of 17
- 03-22-2009, 04:16 PM #1
[SOLVED] I can't run my first applet!!
Hi!!! I'm a REAL beginner and just stumbled upon my first problem :(
I have this code in a applet with extension .java and when I try to run the HTML file that uses the compiled file of this applet´s class I get this error:
the class HelloAgainApplet.class> does not exist (I'm translating the real message into English for you to understand it.)
As well as: java.lang.ClassNotFoundException: HelloAgainApplet.class>
THANKS for your comments/help
APPLET:
import java.awt.Graphics;
import java.awt.Font;
import java.awt.Color;
public class HelloAgainApplet extends java.applet.Applet{
Font f = new Font("TimesRoman", Font.BOLD, 36);
public void paint(Graphics g){
g.setFont(f);
g.setColor(Color.red);
g.drawString("Hello again!", 5, 25);
}
}
- 03-22-2009, 05:44 PM #2
Member
- Join Date
- Dec 2008
- Posts
- 32
- Rep Power
- 0
do u have the .class file in the same directory as ur html file???
- 03-22-2009, 07:02 PM #3
Compile the Java code
Once you have the .java file ready, you have to compile it to convet it into a .class file before it will run.
Trail: Getting Started (The Java™ Tutorials)
Compiling and Running the Examples: FAQs (The Java™ Tutorials)
Luck,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 03-22-2009, 07:39 PM #4
files
I only have these files and in the same directory
HelloAgainApplet.java(Java-file)
HelloAgainApplet.class(CLASS-file)
HelloAgainApplet.html(Firefox.-doc)
-------
Am I supposed to have another file to run the applet???
When I did the first example in the book I had these 5 files:
1-HelloWorld.java(JAVA-file)
2-HelloWorld.class(CLASS-file)
3-HelloWorldapplet.java(JAVA-file)
4-HelloWorldapplet.class(CLASS-file)
5-HelloWorld.html(firefox-doc)
- 03-22-2009, 07:47 PM #5
- 03-22-2009, 07:54 PM #6
CJSLMAN.
I did compile my java file and I have the class of that file. It happens now that it seems that I´m missing one or two files. Do I need anything else to run my applet?
- 03-22-2009, 07:55 PM #7
Who's on first?
Did your first applet run (HelloWorldApplet.class)? or is the HelloAgainApplet.class your first applet?
A couple of things:
- Always post all code and complete error msgs. If the code is too long, then a sample code is perfered.
- There is a subforum specific to Java applets were this might get more exposure.
Luck,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 03-22-2009, 08:06 PM #8
Yes, my HelloWorldApplet (my first applet) did run. Not the second (HelloAgainApplet).
- 03-22-2009, 08:17 PM #9
OK... so it's not the installation of the JDK. Let's see the code of the .java file and the .html.
Luck,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 03-22-2009, 08:30 PM #10
//my code (.java)
import java.awt.Graphics;
import java.awt.Font;
import java.awt.Color;
public class HelloAgainApplet extends java.applet.Applet{
Font f = new Font("TimesRoman", Font.BOLD, 36);
public void paint(Graphics g){
g.setFont(f);
g.setColor(Color.red);
g.drawString("Hello again!", 5, 25);
}
}
- 03-22-2009, 08:32 PM #11
// and my html
<HTML>
<HEAD>
<TITLE>Another Applet</TITLE>
</HEAD>
<BODY>
<P>My second Java Applet says:
<APPLET CODE ="HelloAgainApplet.class>" WIDTH=200 HEIGHT=50>
</APPLET>
</BODY>
</HTML>
- 03-22-2009, 08:48 PM #12
and this
I see that there's no file with:
public static void main(String args[])
Do I need a Java application for this applet to run?
- 03-23-2009, 12:27 AM #13
Member
- Join Date
- Dec 2008
- Posts
- 32
- Rep Power
- 0
- 03-23-2009, 06:38 AM #14
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
- 03-23-2009, 02:58 PM #15
Thanks, I'll try again.
- 03-23-2009, 03:15 PM #16
a "<" that got lost
Thanks Webuser! it was an ">" that caused this error, just as Tomiu said!
thank everyone!!:o
- 03-23-2009, 03:25 PM #17
Similar Threads
-
Calling another applet on click of button in one applet
By niteshwar.bhardwaj in forum Java 2DReplies: 1Last Post: 02-19-2009, 12:54 PM -
need applet help !
By fadiRU in forum Java AppletsReplies: 2Last Post: 02-08-2009, 02:29 AM -
Applet in a GUI
By serfster in forum New To JavaReplies: 1Last Post: 06-12-2008, 11:09 PM -
First Applet HELP????
By nvidia in forum New To JavaReplies: 0Last Post: 08-13-2007, 10:11 PM -
Applet, To center text and To open I engage in a dialog in an Applet
By Marcus in forum Java AppletsReplies: 4Last Post: 06-08-2007, 06:15 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks