title: Is it possible to compile to machine code in Java without an external program?
body: <p>First of all, this is not your standard "I want to compile Java code to machine code" question.</p>
  
  <p>I'm working on a compiler written in Java, that will translate a certain language (in my case: Brainfuck) to x86 Assembly, after that I'm currently planning to use NASM and GCC to produce machine code.</p>
  
  <p>Seeing as the HotSpot JVM can compile Java bytecode to machine code, I assume there is some mechanism available to compile source code of type A to machine code.</p>
  
  <p>Is there any way to use this in a compiler written in Java? My main goal is to explore the possibility of writing a compiler in Java without relying on external programs, for example GCC and NASM, being available on the path. I do need a C Compiler because I'm linking with the cstdlib as I'm using those functions in my x86 Assembly code.</p>
  
  <p>To clarify, I'm doing the following currently:</p>
  
  <ol>
  <li>Write x86 Assembly to a <code>bf.asm</code> file.</li>
  <li>Transform Assembly to Object code with <code>nasm -f win32 bf.asm</code>.</li>
  <li>Link the Object code with Windows OS and cstdlib libraries with <code>gcc -o bf bf.obj</code>.</li>
  </ol>
  
  <p>I'm searching for the possibilities of replacing the need of using <code>nasm</code> and <code>gcc</code> in steps 2 and 3 and instead do those with Java code.</p>