user1164554
user1164554

Reputation: 13

Running a Java application from RAM

Typically, Java application runs with the start argument - path to .jar or .class .

But how to run a Java if my file in memory?

If these methods do not exist, can possibly compile Java with the argument

byte[] FileFromMemory

or

bufferedreader FileFromMemory

I'm trying to run from С++ application

Upvotes: 0

Views: 388

Answers (2)

Peter Lawrey
Peter Lawrey

Reputation: 533492

You can write a customer classloader to do this or load the class into an existing class loader using reflection. Both approaches are considered very advanced topics so I would reconsider this unless you have many years of Java experience.

The simplest solution is to write the file to disk e.g. a Ramdisk like tmpfs This is a simpler (if less efficient) way to do this.

Upvotes: 4

NPE
NPE

Reputation: 500277

If your code (.jar/.class) resides in RAM and not on a file system, you'll need to provide your own class loader.

Upvotes: 2

Related Questions