title: Vagrant for a Java project: should you compile in the VM or on the host?
body: <p>Here’s the question: When using Vagrant for a Java project (or any compiled language project for that matter), should you compile in the VM or on the host? Also, would you want your IDE and all your development tools to be run from inside the VM as well, or on the host?</p>
  
  <p>It seems to be <a href="https://stackoverflow.com/questions/16364563/is-it-possible-to-use-vagrant-with-intellij">not very well defined</a> exactly how a Java IDE and the compile/deploy process work with a Vagrant VM. Generally my impression is that code is edited on the host, and run on the VM, which works great for non-compiled languages. <a href="https://stackoverflow.com/questions/14904590/is-vagrant-useful-for-java-javaee-developers">Other answers on Stackoverflow</a> have implied that Vagrant is less useful for compiled languages because of the extra compile step, but I still want to see what can be done.</p>
  
  <p>Some things I’ve thought through already:</p>
  
  <p>Why compile on the VM</p>
  
  <ul>
  <li>if compiling on host, java is one more piece of software to install</li>
  <li>if compiling on host, the java version on host must be manually kept up to date with that on the VM</li>
  <li>the corresponding java version on the host might be unavailable (say, on a Mac)</li>
  </ul>
  
  <p>Why have IDE on the VM</p>
  
  <ul>
  <li>tighter integration between environment and IDE, can use shortcuts to run the application</li>
  <li>can connect debugger for java applications without remote debugging (one step run/debug)</li>
  </ul>
  
  <p>Why compile on the host</p>
  
  <ul>
  <li>faster compile times</li>
  <li>want to keep the VM as close to what production looks like as possible</li>
  </ul>
  
  <p>Why have IDE on the host</p>
  
  <ul>
  <li>it’s the vagrant convention to edit code on the host and run it on the VM</li>
  <li>better UI performance (X forwarding and VNC are slow)</li>
  </ul>
  
  <p>What are your thoughts: should I run my IDE from inside the VM or the host? Should I compile from inside the VM or the host?</p>