applets being cached?

Y

yawnmoth

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.
 
T

tim.yates

Try holding CTRL and clicking refresh...

That should clear the cache, and load the new version
 
Y

yawnmoth

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...
 
A

Andrew Thompson

yawnmoth said:
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.
 
Y

yawnmoth

Andrew said:
yawnmoth wrote:
<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 ....


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

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...
 
A

Andrew Thompson

yawnmoth said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top