简体   繁体   中英

How to run a process from memory/RAM as the “current working directory”

In Java 6 on Windows, I am interested in performing the following task, but really not sure how to go about it.

  1. I want to take a zip file
  2. unzip its contents into a spot in memory/RAM
  3. Create a Java Process that will run a .EXE file that exists within that ZIP file
  4. That .EXE must be run while the current working directory is that location in the RAM
  5. I will then need to put another file into that same "current working directory" location space in the RAM.

I know it sounds weird, but it will actually make something much more efficient by doing it this way, so if its possible, it would be great to know.

It sounds difficult, and it will definitely require a lot of stuff that cannot be done in pure Java.

On Linux, I think you would need to do the following:

The commands for creating the "ram disk" file system will be OS specific, and may require root / administrator privilege.


It is unclear whether doing this will be more efficient than using a temporary directory in the file system. I wouldn't attempt this unless there was a clearly demonstrated need for a solution that it more efficient; ie unless you've tried using a temporary directory and found that it is too slow.

Bear in mind that:

  • much (maybe most) of the work of unpacking the ZIP file has to be done either way you do it, and

  • in the conventional case your .exe will probably be reading the files from the expanded ZIP out of the OS'es in-memory disk-block cache (on Linux).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM