need help to start using applet
I am new to java applet and got stuck in using it. I am starting with the clock example provied on web. I download the source code and compiled in JDK1.5.0_06 and try to display the applet in IE browser. As I did the web page using NetBean5.5 web application template, the applet class appeared in the classes folder under WEB_INF. The following is the web page script:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<applet codebase="classes" code="Clock.class" height="200" width="200"></applet>
When I run the web page, the browser just display a grey blank box and the Java console tells me this error message:
Microsoft (R) VM for Java, 5.0 Release 22.214.171.12410
f run finalizers
g garbage collect
m memory usage
t thread list
I have no idea about this. Can anybody help please? Thanks in advance.
This clearly means that browser does not know where the Clock.class file is...
Make sure the html page is in the same location where class file is.
Actually, I didn't put class file in the same folder of the html file. It is in the subfolder named classes, so I put codebase="classes" in the applet tag.
Do I have to always put them in the same folder?
no..but you will have to make sure that the place where you have put ur file is visible to the web page
If I may... and I'm probably wrong but.....
<applet codebase="classes" code="Clock.class" height="200"
I don't believe that this really tells the JVM anything at all about the location of Clock.class. As I understand it, and again, I'm probably wrong, but codebase needs either an actual URL or a relative path. What you are saying here is that the file "Clock.class" is located in the file "classes", which is impossible. It would have to be either....
assuming, of course, that classes is directory inside your root html directory. If not you would need to supply the JVM with the proper navigation.
just to make this work for you....
put ur html page that has applet code in it, in the classes folder,
put ur applet class file in the same folder
now in the applet code in the html page change codebase to this
and then test ur applet...this will give u what this all about that visibility of class and stuff..:-)
I put them in the same folder. It still doesn't work. So I tried to run my applet in Netscape browser and it works fine. It seems something wrong with my IE browser. What can that be? I can run some online applet examples using IE browser but not with my applet.
First thing u always want to do is make sure that you have the JRE correctly installed from ur browsers...(download it from java site and re-install it)
Thanks, Khalid. I re-install the JRE for IE browser and now it works. Thanks a lot for your help.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)