You may find my statement weird, but this is not quite a certain question, because "compile Java code" may mean quite different things. The question would be: compile into what? There is a way to compile Java into CIL code to be run under CLR, of into Java
bytecode to be executed on
JVM. Please see:
http://en.wikipedia.org/wiki/Java_%28programming_language%29[
^],
http://en.wikipedia.org/wiki/Java_virtual_machine[
^],
http://en.wikipedia.org/wiki/Common_Intermediate_Language[
^],
http://en.wikipedia.org/wiki/Common_Language_Runtime[
^].
First option is available with Visual J# (used be be bundled with Visual Studio, v. 2005), but this is, strictly speaking, not really original Java. Please see:
http://en.wikipedia.org/wiki/J_Sharp[
^].
Other alternatives based on CLR include:
http://en.wikipedia.org/wiki/IKVM.NET[
^] (free Java implementation for .NET and Mono),
http://en.wikipedia.org/wiki/JavApi[
^] (Java API for .NET).
How about compiling for real KVM installed in the system? It's always possible. You will understand it if you remember that VS is just the IDE which does not build anything. You can add support of any language by using or developing VS add-ins. Please see:
http://msdn.microsoft.com/en-us/library/80493a3w.aspx[
^] (see the versions of this page for other versions of VS).
—SA