4

Basically, I want to be able execute a byte stream as a file, without writing said bytes to a file.

I want to do this in a windows environment.

You could say I want a to create a file, copy the stream to the file, and open the file as an executable, but I want the file to have no physical manifestation on the disk.

Thanks

Gal
  • 5,338
  • 5
  • 33
  • 55

2 Answers2

3

This is not possible to do using the standard Java API. You will have to rely on some OS specific native implementations, either that do the whole thing for you, or that allow you to create some sort of RAM-disk on which you can place your temporary data and execute it.

Possibly related:

Community
  • 1
  • 1
aioobe
  • 413,195
  • 112
  • 811
  • 826
  • This RAM-disk seems interesting and just might be what I need... any information on how do it in Windows? – Gal May 10 '12 at 07:12
  • 2
    Google for *ramdisk windows*. You'll find lots of free software. Read up on how to control one through the command line. Use `ProcessBuilder` to create the ram-disk, write the bytestream to the ram-disk, use `ProcessBuilder` again to execute the bytestream from the ram-disk. – aioobe May 10 '12 at 07:18
1

Supposing you bytestream is the one of a standard exe, and you don't want to call a whole virtualisation environnement, the short answer is no because internal adresses in the code wouldn't map.

Here's a more detailled answer :

process.start() embedded exe without extracting to file first c#

Community
  • 1
  • 1
Denys Séguret
  • 372,613
  • 87
  • 782
  • 758