Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3


You can use IKVM to access your boo assemblies from java or access java classes from boo.

IKVM is an open source java runtime for .NET and Mono. It has tools to create .NET dlls that wrap java classes and libraries (ikvmc) or conversely, create a stub java class that wraps a .NET dll or exe (ikvmstub). So you can call .NET (boo) functions from java or vice versa.

Accessing boo assemblies from java

This example shows how to run booish from java:

Accessing java libraries from boo

Java Vector sample

This uses IKVM's IKVM.GNU.CLASSPATH.dll which wraps java's standard libraries:

Code Block
import java.util from "IKVM.GNU.CLASSPATH" //or reference the dll
v = Vector()
print v

Java.AWT sample:

This AWT example still needs some work. I don't think Java's Swing will work with IKVM though. However, there is an open source clone of Swing called SwingWT that will work with IKVM.

Code Block
// (needs work)
import java.awt from "IKVM.GNU.CLASSPATH"
class Hello(Frame):
    def constructor():
        hello = Label("Hello World")
h = Hello()

Another Alternative: Converting Java Code to Boo Code

If you have a copy of Visual Studio .NET 2003 or 2005, you can install and run the JLCA tool from Microsoft to convert java code to C# code. This will even do things like convert "getWidth/setWidth" methods into properties, and convert java swing stuff into windows.forms code. It generates a report listing any specific issues it had with the conversion, as well as including the same notes as comments in the generated files.

You can then use the online code converter tool used by SharpDevelop to convert the generated C# code into boo code. Comments are preserved throughout both the JLCA and SharpDevelop conversions.

This may be a better option than IKVM for example if the java app uses java swing (which IKVM cannot run), or if you want to convert the source so that the application can be optimized for the .NET/Mono platform.