Help with First Cup of Java Tutorial

Hello everyone,

I am new to java (just downloaded the J2SE 1.4.2 SDK and am running on a Windows 2000 system) and have started my learning process by going through the First Cup of Java tutorial. I completed the tutorial, ran my hello.html from the appletviewer. The appletviewer displayed the desired "Hello World!" text and everything seems great. My question is..... when I open the Hello.html file from my Microsoft Internet Explorer, my screen displays"Here is the output of my program: " followed by a gray box. Shouldn't "Hello World" be in the gray box?Why is the appletviewer different than my browser?

Thanks in advance.

Janet

[669 byte] By [j_peterson] at [2007-9-30 4:41:30]
# 1
Use the Java Console of IE browser - it will likely show you an error message. You might need to enable the Java Console using the IE options. Also, make sure the IE options are set to use the Sun Java.
atmguy at 2007-7-1 14:25:26 > top of Java-index,Administration Tools,Sun Connection...
# 2
What component you're using for the text output ?Since you applet is not huge :-) you could copy-paste the code here :-)
Piligrim at 2007-7-1 14:25:26 > top of Java-index,Administration Tools,Sun Connection...
# 3

Here is the file Hello.html:

<HTML>

<HEAD>

<TITLE>A Simple Program</TITLE>

</HEAD>

<BODY>Here is the output of my program:

<APPLET CODE="HelloWorld.class" WIDTH=150 HEIGHT=25

></APPLET>

</BODY>

</HTML>

Here is the HelloWorld.java file that I compiled using javac to get my .class file:

import java.applet.*;

import java.awt.*;

public class HelloWorld extends Applet {

public void paint(Graphics g) {

g.drawString("Hello World!", 50, 25);

}

}

Here are the results from the java console:

Error loading class: HelloWorld

java.lang.NoClassDefFoundError

java.lang.ClassNotFoundException: HelloWorld

at com/ms/vm/loader/URLClassLoader.loadClass

at com/ms/vm/loader/URLClassLoader.loadClass

at com/ms/applet/AppletPanel.securedClassLoad

at com/ms/applet/AppletPanel.processSentEvent

at com/ms/applet/AppletPanel.processSentEvent

at com/ms/applet/AppletPanel.run

at java/lang/Thread.run

Error loading class: HelloWorld

java.lang.NoClassDefFoundError

java.lang.ClassNotFoundException: HelloWorld

at com/ms/vm/loader/URLClassLoader.loadClass

at com/ms/vm/loader/URLClassLoader.loadClass

at com/ms/applet/AppletPanel.securedClassLoad

at com/ms/applet/AppletPanel.processSentEvent

at com/ms/applet/AppletPanel.processSentEvent

at com/ms/applet/AppletPanel.run

at java/lang/Thread.run

Thanks for telling me about the java console, I'm not sure what the error message is telling me.

j_peterson at 2007-7-1 14:25:26 > top of Java-index,Administration Tools,Sun Connection...
# 4

The error message is like a stack trace - the last thing that happened is on top and the first thing on bottom. So the message is saying the HelloWorld.class file was not found.

I think if you have Hello.html and Hello.class in the same directory and have Internet Explorer configured to use Sun Java then it will work.

atmguy at 2007-7-1 14:25:26 > top of Java-index,Administration Tools,Sun Connection...
# 5

The files are both in the same directory... I do not see anywhere in

IE where I can set it up to use Sun Java.

> I think if you have Hello.html and Hello.class in the

> same directory and have Internet Explorer configured

> to use Sun Java then it will work.

j_peterson at 2007-7-1 14:25:26 > top of Java-index,Administration Tools,Sun Connection...
# 6
In IE select Tools menu, Internet Options. Click on Advanced tab. Scroll down until you see Java.
atmguy at 2007-7-1 14:25:26 > top of Java-index,Administration Tools,Sun Connection...
# 7
1. select IE in "Control panel" -> "Java Plug in" -> "Browser TAB"2. you can use HtmlConverter.exe that resides in Java\Bin directory to convert your HTML to "Sun JRE requiring" page.good luck
Piligrim at 2007-7-1 14:25:26 > top of Java-index,Administration Tools,Sun Connection...
# 8
The problem turned out to be that I did not have J2RE installed. Since I do not want to inconvenience my customers by forcing them to download this , I compiled with an older version of java and everything works great!Thanks for your suggestions.
j_peterson at 2007-7-1 14:25:26 > top of Java-index,Administration Tools,Sun Connection...
# 9
j_peterson the only problem is that MS stopped distributing their JRE with Windows XP and later :-)
Piligrim at 2007-7-1 14:25:26 > top of Java-index,Administration Tools,Sun Connection...