Bank memory execution

Suppose I have a java process that receives a runnable jar file from a trusted process in byte [] form, is there a way to call it without writing the jar file to disk and then call it (start a new process that starts the jar) ?

+5


source to share


2 answers


Here's one way to achieve it:



  • Create ByteArrayInputStream

    from received byte []

    .
  • Now use JarInputStream

    to create an in-memory view of the jar file.

    ByteArrayInputStream bis = new ByteArrayInputStream(byteArray); JarInputStream jis = new JarInputStream(bis);

  • So you have a flask loaded into memory.

  • You can now use custom classloaders for further processing. Here's one example you can refer to.
+8


source


The simplest approach is to write it to a ramdisk and eliminate the idea entirely in memory.



+2


source







All Articles