1

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.

2
  • 1
    the JavaCompiler class can be used to work entirely in memory (i wrote a libray to do this some years ago) not that it makes much difference. ;-) Commented Dec 25, 2012 at 13:21
  • +1 @PeterLawrey, is this library open source? Commented Dec 25, 2012 at 19:09

3 Answers 3

4

Can you check out the following

Sign up to request clarification or add additional context in comments.

1 Comment

+1 to both, one of this is exactly I need; now I've to spend some time to understand which API is simpler for my task (compile in memory a mathematical expression, for now)
1

You need to play with the class loader to load dynamically some class. There are some interesting SO questions on the subject:

Comments

-1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.