0

In particular - the Applet.class. How could I find where it locally resides? I have tried the following, but I get an exception:

 System.out.println(JApplet.class.getProtectionDomain().getCodeSource().getLocation().getPath());

It is of course somewhere in Program Files/Java/jdk_7_xx/ but I have had quite a look around and searched online and cannot find the answer. I have always wondered where specific classes reside on the system.

Note: If you want some more detail (not necessary to read below this):

What I specifically want to do is edit the Applet.class and point my Eclipse to a new JRE System Library that contains the edited Applet.class. In theory this sounds plausible, yet in practice I am unsure.

This is needed so I can test legacy code which keeps making calls to super methods - I have tried many frameworks/approaches and tried multiple possible solutions that have been posted on stack overflow and other online resources - none work.

DeaIss
  • 2,525
  • 7
  • 27
  • 37
  • *"In theory this sounds plausible, yet in practice I am unsure."* You (or anyone for that matter) has a snow-ball's chance in Hell of achieving that. – Andrew Thompson Dec 13 '13 at 11:24
  • Nope. You can not do that. – Nishan Dec 13 '13 at 11:25
  • Alright - cheers! Theorycrafting at its best... Anyway, Back to the original question - do you know how I can find the specific path of the Applet.class? I'm assuming its in a jar somewhere? – DeaIss Dec 13 '13 at 11:27
  • this should be of some help http://stackoverflow.com/questions/227486/find-where-java-class-is-loaded-from/227569#227569 – harsh Dec 13 '13 at 11:58

2 Answers2

0

Found the JApplet.class in C:\Program Files (x86)\Java\jdk1.7.0_25\jre\lib\rt.jar

Made a back-up of jdk1.7.0.25 on my desktop and put it in a folder Desktop\BACKUP\jdk1.7.0.25

Unzipped it (rt.jar), decompiled Applet.class with jad, changed some methods and even added a new one, recompiled it, rezipped it, replaced the old rt.jar with the new one, made a new eclipse project and made it use the JRE in Desktop\BACKUP\jdk1.7.0.25 and it worked perfectly.

DeaIss
  • 2,525
  • 7
  • 27
  • 37
-1

..do you know how I can find the specific path of the Applet.class?

For your own PC? Sure. For the PC of a client of your applet? No.

In fact, Oracle (or was it Sun?) eventually decided it was not the business of an app. launched within the Java Plug-In (e.g. applets or JWS apps), to know where the classes were cached. Not even it that app. was fully trusted.

I'm assuming its in a jar somewhere?

Don't assume. It is set in the Java Control Panel, which defaults to 'no compression'.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433