Reputation: 3392
Is there a way to emit Java bytecode in memory and execute it?
I know that there's JavaCompiler
class, but I'm asking something like Reflection.Emit
of .NET
platform.
Upvotes: 1
Views: 750
Reputation: 11465
You need to play with the class loader to load dynamically some class. There are some interesting SO questions on the subject:
Upvotes: 1
Reputation: 11950
This is possible but this requires the end user also to install JDK
. Compile the bytecode to memory and create a new java process and start it. You can also execute java source
directly.
See Beanshell2
.
Upvotes: -1