Tutorial :Read Java Variables


I am trying to achieve reading variables from a Java applet out of process from my C# program. Apart from reading memory addresses, is there any way I can obtain values of variables from a java applet? This java applet will be running inside a browser. If it is not possible to do this from C#, would it be possible to do it from a different java applet?



If you can change the code of the applet, you can have it host an RMI server, which is the subject of this excercise. I'm not an expert of the subject though - I assume it may be subject to various security restrictions.

If you can't change the applet, but you can change the HTML page showing the applet, there are two ways to access information from the applet.

The first way is scripting the applet with Javascript like @Margus suggests (all public methods of the applet object are exposed via the applet's DOM object).

The other way is putting an applet of your own in the page, and use getAppletContext() to obtain a reference to the other applet. The main benefit of doing it this way is that you can access non-public information from the third-party applet via reflection, and publish it with an RMI server (as above).


Yes, it can be done.

C# form can have can host webbrowser component, and it can fire JScript, and it can call Java applet public methods.

While ago, i made a simple webpage, that hosts an applet that draws 'hot'-colored map. Input is injected with JScript, and COULD be retrieved with AJAX or any other application that can fire JScript on HTML DOM.

Source of HTML is:

<HTML><HEAD></HEAD><BODY>   <SCRIPT>   function call() {      var inputData = "-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2"          + ";-2,-2,-2,-2,-2,-2,-2,-2,-2,0,1647,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2"          + ";-2,-2,-2,-2,-2,-2,-2,-2,-2,89,0,-1,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2"          + ";-2,-2,-2,-2,-2,-2,-2,0,0,615,366,0,1198,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2"          + ";-2,-2,-2,-2,-2,-2,0,2179,1262,764,200,0,0,609,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2"          + ";-2,-2,-2,-2,-2,0,0,3401,1940,0,210,0,-1,-1,162,0,0,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2"          + ";-2,-2,-2,-2,-2,-2,0,-1,966,0,86,0,0,0,0,-1,-1,0,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2"          + ";-2,-2,-2,-2,-2,-2,-2,0,0,0,0,0,0,0,-1,250,53,-1,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2"          + ";-2,-2,-2,-2,-1,1977,1413,128,0,0,0,0,0,0,-1,1413,2447,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2"          + ";-2,-2,-2,0,-1,0,0,0,0,0,0,0,-1,317,0,-1,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2"          + ";-2,-2,-2,0,0,0,0,0,0,0,0,0,0,3246,2190,0,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2"          + ";-2,51,0,-1,0,0,0,-1,0,-1,0,-1,-1,1523,-2,-2,-2,-1,0,0,-2,-2,0,0,-2,-2,-2,-2,-2"          + ";-2,0,0,0,0,0,0,0,0,0,0,1692,2028,2850,-2,0,-1,0,0,0,0,0,0,0,-1,-2,-2,-2,-2"          + ";-2,0,0,0,0,0,-1,0,0,0,-1,1292,-2,-2,-2,0,0,-1,-1,0,0,0,0,0,-1,0,-2,-2,-2"          + ";-2,0,-1,0,0,-1,0,0,-1,0,1028,1247,7675,9244,7940,0,-1,0,0,-1,0,0,0,0,0,0,0,-2,-2"          + ";-2,-1,0,0,0,0,0,0,0,0,844,1114,2860,6631,4249,0,0,-1,-1,0,0,0,0,0,0,0,0,-2,-2"          + ";-2,-2,0,0,0,-1,0,-1,0,0,0,-1,1958,2379,-1,0,0,0,0,0,0,0,0,-1,0,0,0,-2,-2"          + ";-2,-2,-2,0,470,0,-2,-2,-2,0,0,0,-1,0,0,0,0,0,-1,0,-1,0,0,3574,2706,2195,-1,-2,-2"          + ";-2,-2,-2,-2,-2,-2,-2,-2,-2,0,0,0,-1,-1,0,0,0,0,0,0,0,0,165,-1,-1,1282,867,0,-2"          + ";-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,0,0,0,0,0,0,-1,0,0,0,0,34,504,3098,2708,2324,-1,0,-2"          + ";-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,0,0,-1,0,0,0,0,0,0,0,0,0,721,-1,3854,2783,-1,0,-2"          + ";-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,0,0,0,0,0,-1,0,0,0,-1,0,34,191,2455,4126,0,0,-2"          + ";-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,0,0,0,0,0,0,0,0,3982,2656,0,0,-1,0,0,-2,-2"          + ";-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,0,-1,0,0,2194,0,0,0,0,-2,-2,-2,-2"          + ";-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,0,0,-1,0,0,-2,-2,-2,-2,-2,-2,-2"          + ";-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2";      document.Necrodrip.update(inputData);  }  </SCRIPT>   <FORM>   <APPLET CODE="kuningriik.pdApplet.class"            NAME="Necrodrip"           width="1200" height="600">   </APPLET><br/>   <INPUT type="button" value="Loo kaart"      onClick = "call()">   </FORM>   </BODY></HTML>   

You can view page here: link


This is not possible, at all.

Processes, by definition, do not share memory, or any other resource for that matter. This is something that is enforced at the OS level, and you cannot do anything about that.

If this was possible, you could only imagine what security/stability issue this might have been.

If you really need inter-process communication, check out socket programming in your language. Note that this will require changes both to the client (your Java applet) as well as the server (the C# process).


You can access information from running Java process (including in a browser) if you have a JDK installed and are running a later JVM. Take a look at these JDK tools.


This is what debugger do all the time, so clearly it is possible. In recent versions of Sun Java you attach JVM Tool Interface (JVMTI) relatively easily after a process has started. However, it's not necessarily very easy.

If you control the applet source(or even if you don't), it's probably easier to share data over a network connection.


No. What you are trying to do is impossible from a Java Applet or from any other language, process.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »