title: Run code from input like if it was written in the source code
body: <p>I'm currently writting a TCP/IP client in Java. The only thing that the client should be able to do is to run code that the server sends to it.
  I have seen <a href="https://stackoverflow.com/questions/10455752/how-to-execute-console-or-gui-input-as-if-it-was-actual-java-code">this question</a> , but my problem is that the code would be ran like if it was another application, but if the client code contains a string and the server sends a message saying, read the string and send back the content, then the client would not be able to do so because that code would be executed in another program where that string dosen't exist :-(</p>
  
  <p>So is there a way that i can run code from a input like if it was written in the source code of the program?</p>
  
  <p>All help is much appreciated :-)</p>
  
  <p>Example:</p>
  
  <p>The client contains a string that says "string0001".
  The client should run the code that the server sends.
  The server sends a block of java-code that the client shouls be able to execute.
  The code says: check content of string and send it back to this ip.
  The client should now be able to read the string and send back "string0001" to the servers ip.</p>
  
  <p>With the solution that the link provided, the code that the server sent would be executed like if it was another program, and in that program the string that the server requested the client to read does not exist.</p>
  
  <p>The client whould now be able to run the code like if it was written in the clients source, where the string exist.</p>
  
  <p>Hope that helps :-)</p>