gsscoder
gsscoder

Reputation: 3392

Compile Java in memory

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

Answers (3)

Seki
Seki

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

Sri Harsha Chilakapati
Sri Harsha Chilakapati

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

Jayamohan
Jayamohan

Reputation: 12924

Can you check out the following

Upvotes: 4

Related Questions