TODO: Convert to the MediaWiki formatting as discussed at Converting Old MinGWiki Pages [3]
When you first download and install the MinGW Java compiler (gcc-java), you may find that when you try to compile a Java program with gcj, you get an error saying "cannot find -liconv". This is because gcj automatically attempts to link your program with libiconv, which is not distributed with MinGW and must be downloaded and installed separately. To get your Java program to compile, download libiconv from http://gnuwin32.sourceforge.net/packages/libiconv.htm [4]. You want "Binaries" and "Developer files". Unzip both downloaded files to your MinGW directory.
You should now be able to successfully compile a Java program. You might try the following as an example. Type this code into a file named Test.java:
public class Test
{
public static void main(String args[])
{
System.out.println("This is a test.");
}
}
Now compile it:
gcj --main=Test Test.java
There should now be a file named a.exe in the directory where you compiled the program. Run it and you should get the following output:
This is a test.