First of all, don't do this from a JSP. At the very least, do it in a backing bean.
If the code is an executable you might use Runtime.exec or ProcessBuilder to run it;
this article talks about some of the pitfalls.
Accessing an object file is trickier. If it's a DLL you can use a Java/DLL bridge like Jacob.