Make executable archive just like Java's .jar archive?

Mike Parker aldacron at
Thu Sep 12 13:23:03 UTC 2019

On Thursday, 12 September 2019 at 12:53:27 UTC, BoQsc wrote:
> On Thursday, 12 September 2019 at 12:52:48 UTC, BoQsc wrote:
>> Is there a way to archive multiple .d source code files and 
>> make that archive executable, or something similar?

A JAR file is just a standard zip file. The Java Virtual Machine 
loads .class files (which are Java bytecode files, not Java 
source) and executes them at runtime. It doesn't matter if 
they're in a jar file or not. Java was designed for this from the 

If you're really talking about loading .d *source* files, that 
means they either have to be interpreted like a scripting 
language, in which case you'll need a D interpreter, or they'll 
need to be compiled at runtime into bytecode (in which case 
you'll need a bytecode interpreter), or compiled at runtime into 
object files, in which case you'll need a mechanism for loading 
object files into a program (there was an object loader library 
around back in the D1 days).

If you want to do what Java does and compile ahead of time to a 
bytecode format and distribute the bytecode in an archive to be 
loaded at runtime, then that requires implementing a bytecode 
compiler, a loader, and a bytecode interpreter.

I know that LLVM can output bytecode, so with LDC that's the 
first step out of the way. Now all you need is for someone to 
implement a loader and bytecode interpreter.

More information about the Digitalmars-d-learn mailing list