Suppose I have a java process that is receiving a runnable jar file from a trusted process in the form of a byte [], is there a way to invoke it without having to write the jar file to disk and then invoke it(start a new process that is running the jar)?
Most JAR files are simply containers for data that another program needs to run with Java; therefore you cannot run these files and nothing will happen when you double-click them. Similarly, most executable JAR files are downloaded as installation files to install applications or programs.
Right click on your Java Project and select Export. Select Java -> Runnable JAR file -> Next. Select the Destination folder where you would like to save it and click Finish.
If you can't run jar files on your Windows 10 PC, you might need to reinstall Java Runtime Environment. When JAR files are not opening, another great method is to simply use a universal file opener. Alternatively, some reported that turning your JAR file into a BAT file worked perfectly.
Here is one way you can accomplish it:
ByteArrayInputStream
from the byte []
received.Now use JarInputStream
to create in-memory representation of the jar file.
ByteArrayInputStream bis = new ByteArrayInputStream(byteArray);
JarInputStream jis = new JarInputStream(bis);
This way you have the jar loaded in the memory.
The easiest approach would be to write it to a ramdisk and avoid the in-memory idea completely.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With