Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2006

Tip: Looking for answers? Try searching our database.

applets being cached?

Thread view: 
yawnmoth - 15 Aug 2006 15:17 GMT
I compiled a file - HelloWorld.java - and then included it on a webpage
and got "Hello world!" displayed back to me.  I then change the text
from "Hello world!" to "test", recompiled it, and upon hitting the
refresh key in the browser, I still see "Hello world!" - not "test".
Any ideas as to what the problem is?  It almost seems as if java
applets are maybe being cached or something...

Here's HelloWorld.java:

import java.applet.Applet;
import java.awt.Graphics;

public class HelloWorld extends Applet {
   public void paint(Graphics g) {
       g.drawString("Hello world!", 50, 25);
   }
}

The browser I'm using is FireFox.
tim.yates@gmail.com - 15 Aug 2006 15:30 GMT
Try holding CTRL and clicking refresh...

That should clear the cache, and load the new version
yawnmoth - 15 Aug 2006 15:51 GMT
> Try holding CTRL and clicking refresh...
>
> That should clear the cache, and load the new version
It doesn't seem to do anything for Java, atleast.  In fact, I just
deleted the *.class file and I'm still getting the "Hello world!"
message.  From a non-existant *.class file, no less...
Andrew Thompson - 15 Aug 2006 16:43 GMT
> > Try holding CTRL and clicking refresh...
> >
> > That should clear the cache, and load the new version
> It doesn't seem to do anything for Java, atleast.  In fact, I just
> deleted the *.class file and I'm still getting the "Hello world!"
> message.  From a non-existant *.class file, no less...

Browsers are notorious for caching applet classes.

The best (& only reliable) method I've found is to
tell the JVM to load the classes afresh.  This can
be achieved by opening the Java console ....

Java Plug-in 1.5.0_01
Using JRE version 1.5.0_01 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Administrator
----------------------------------------------------
.....
x:   clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------

...and typing 'x' to clear the classloader cache.

Of course, you can remeber to do that every time you
reload the applet in the browser, or you can take either
of two other courses of action that completely avoid the
problem.  I.E.

Develop and test applets in either
- The AppletViewer
- A Frame

HTH

Andrew T.
yawnmoth - 15 Aug 2006 17:19 GMT
> <snip>
> The best (& only reliable) method I've found is to
[quoted text clipped - 11 lines]
>
> ...and typing 'x' to clear the classloader cache.

It wouldn't be possible to do that from the commandline, would it?  I
ask because I'm currently using a batch file to call javac (since its
exact path is kinda long).  Clearing the cache doesn't seem all that
unreasonable a thing to do from it, either...
Andrew Thompson - 15 Aug 2006 20:40 GMT
> > <snip>
> > The best (& only reliable) method I've found is to
> > tell the JVM to load the classes afresh.  This can
> > be achieved by opening the Java console ....
...
> > ...and typing 'x' to clear the classloader cache.
>
> It wouldn't be possible to do that from the commandline, would it?

The browser must be loaded for the JVM to be
loaded (for the cache to be cleared).

So - no.  Not without some JNI magic, in any case
(in which case, it would be both platform and browser
specific AFAIU).

OTOH - if you use the command line to launch the
appletviewer (have you looked at the documentation
on it?) it makes the entire question moot.

>...I
> ask because I'm currently using a batch file to call javac (since its
> exact path is kinda long).  Clearing the cache doesn't seem all that
> unreasonable a thing to do from it, either...

Clearing the cache is entirely unnecessary when using
either of the methods that you trimmed.

Why do neither of those suggestions work for your
situation?

Andrew T.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.