views:

52

answers:

3

I am just learning Java applets. When I changed my code, it doesn't update if I refresh the page, but it does when I close the entire browser and open it again. I'm using eclipse as my IDE.

Is there some setting I'm missing? Or is the only way to do it?

A: 

when you change your code, you should build the application, after you should refresh full page (using Shift + F5).

RyuuGan
I have it on Build automatically (but I have tried manually Building), and the Shift+F5 doesn't do anything, on Firefox or IE.
yuudachi
+1  A: 

Consider using the built-in Eclipse applet viewer.

On Windows, the shortcut is ALT-SHIFT-X, then A (or ALT-SHIFT-D to debug).

Alternatively, go to Run->Run As...->Java Applet.

This will not only let you run/debug quicker, but it will also make sure your latest changes are there, and will even allow hot replace of code (often no need to even restart the applet to apply changes).

Mark Peters
What if I want to use the <PARAM> tag or code from the HTML page?
yuudachi
@yuudachi: You can customize the Run Configuration (Run->Run Configurations). Click on your configuration under Java Applets on the left (or, if you haven't run it yet as an applet, create a new Java Applet configuration) then go to the Parameters tab and add the parameters you want.
Mark Peters
As for using code from the HTML page (I'm guessing you mean Javascript?) you're probably better off in a browser for that.
Mark Peters
+1 That's handy! NetBeans has a similar feature.
trashgod
+1  A: 

You can enable the Java Console, which includes several useful commands. In particular, x: clear classloader cache may be helpful.

c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
l:   dump classloader list
m:   print memory usage
o:   trigger logging
p:   reload proxy configuration
q:   hide console
r:   reload policy configuration
s:   dump system and deployment properties
t:   dump thread list
v:   dump thread stack
x:   clear classloader cache
0-5: set trace level to 

Addendum: The Java Console is sometimes the only way to see certain problems early in the applet life cycle, but a hybrid approach is sometimes convenient. You can use your IDE to debug the program as an application and then deploy it as an applet or via Java Web Start.

trashgod
worked like a charm, thank you!
yuudachi