• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get applet work in browser

 
Mindy Wu
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I just created a fun game by using applet. It works fine in appletviewer, but when I try to view it in the browser, it shows nothing but a empty gray image.
In the browser's status bar, i saw XX.class not found when I mouse over on the image.
Thanks!
 
lee dalais
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what browser are u using, i've had problems with older browsers not finding the classes, newer browsers should wrk, eg: ie5
 
Matt DeLacey
Ranch Hand
Posts: 318
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure your classpath is correctly set. it should be set to include the dir that the .class file is in.
Matt
 
Mindy Wu
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Explorer 5. But, I don't know how to set up the classpath. I installed JDS in C drive and save all my other java programs in D drive. Can you give me a guide of how to set up the classpath properly, please.

Thank you very much!
Mindy
 
Jan Volkmann
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mindy Wu:
[I]Can you give me a guide of how to set up the classpath properly, please.
I]

Keep the *.html file in the same directory as the applet's class file is in. Edit the html file and remove codebase from the applet-tag. Insert code="[I]AppletName[I].class" if necessary.
Do not use packages unless you like asking for troubles. Although Sun claims it to be possible
cf. http://web2.java.sun.com/docs/books/tutorial/applet/overview/test.html
I spent three days on it without success. When the applet is loaded the JVM apparently interprets the package-statement as part of the path and looks for the applet class in yet another subdirectory named after the package. I would do so until Kingdom Come, I suppose.
An IDE's appletviewer is much smarter in a way. It has the advantage of having more info about paths'n'packages so it let's you get away with lots of things. This is not beneficial, I think 'cos it is often misleading when trying to detect an error.
hope it helps,
Jan
 
Matt DeLacey
Ranch Hand
Posts: 318
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you trying to use IE to view an applet on your PC or on a server? If you are trying to view it on your PC, then put the applet in the same dir as your .html file and then if your
applet .class file is in d:\iamcool\whyislifesofunky then
to set your classpath type set CLASSPATH=d:\iamcool\whyislifesofunky;%CLASSPATH%
Try this. If this doesn't work let me know.
It is also possible that you don't have support for
Java turned on in your browser...you might check that.

With Respect,
Matt
 
Mindy Wu
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your kindness. However, I still could not get it work. I do run my program at my local PC, and I did have Java enabled in my browser. I try to setup the classpath in dos as you instructed, for example: my class is in d:\My_Room\Java1.3\game.class. I included this directory in my html file, but it is still not working. Actually, after I installed the Standard Java Development Kit, I never setup any classpath in dos, and I still don't know how, can you give me more assistance. Thanks again.
Mindy
 
Matt DeLacey
Ranch Hand
Posts: 318
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's see, I'm all confused because I'm running a server at home
and I do applets on another server and then run them locally. So, I may have given bad advice. Can you show your .html file
and what you type in to the http:// field of your browser? It should be as simple as: if your .class file that you want to load is in c:\mattiscool, then set your classpath to that dir. Just to get you up and running, opne a dos window and type
set path=c:\jdk1.2.2\bin;%PATH%
set classpath=c:\mattiscool;%classpath%
then go to your browser and in the http field type
c:\mattiscool\coolApp.html
where coolApp.html looks something like
<html>
<applet code = coolmatt.class height = 400, width = 400>
</applet>
</html>
That SHOULD do it. Let me know if it doesn't.
 
Steven YaegerII
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I'm throwing in a classpath/path link. It's pretty handy. You have to click about three pages into the tutorial to get to the stuff about classpath & path statements
<a href="http://www.naviseek.com/book/java2412/jdkhelp1.shtml"> http://www.naviseek.com/book/java2412/jdkhelp1.shtml
</a>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic