13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

182Chapter 7The GNU Compiler for Java (gcj)Even if this were not so, it is not permissible under the GPL to distributebinaries without also offering to distribute source code. So, to distribute theSun or IBM API JAR files would be incompatible with the GPL, and to notdistribute them but to depend <strong>on</strong> them would mean shipping a product thatdoesn’t work out of the box and requires users to obtain some n<strong>on</strong>-Free softwarein order to work. That is just not acceptable. So the developers of gcj haveopted to reimplement as much of the Java APIs as possible.As you can probably guess if you have browsed the Java API Javadoc files,this is a m<strong>on</strong>umental undertaking. The Java APIs are a moving target, and theystarted huge and grow larger with every new release. There is a parallel projectto gcj called GNU Classpath 8 which is attempting to implement the entire JavaAPI. Its target for the 1.0 release is to be fully compatible with Java 1.1 and“largely compatible” with Java 1.2. You might want to look at that project forbetter API support than that provided by gcj’s libgcj. 9 If you are curiousabout the present status of libgcj’s implementati<strong>on</strong> of the Java APIs, there isa Web page (frequently updated) that compares the status of it against theJava 1.4 packages. 107.4.1 Compiling FetchURL with gcjWe’ll discuss gcj’s command-line switches in detail in Secti<strong>on</strong> 7.5, but we willhave to use a couple of them here. First off, be aware that since gcj is actuallypart of gcc, all of the n<strong>on</strong>-language-specific switches of that system also workin gcj; thus, -o specifies the name of the binary output file, and so <strong>on</strong>. Thereare many references <strong>on</strong> gcc to which you should refer for details (the manpage<strong>on</strong> gcc is a good place to start). Example 7.1 shows compiling and runningFetchURL with gcj.8. http://www.gnu.org/software/classpath/9. The gcj and GNU Classpath projects are in the middle of an effort to merge their librariesinto a comm<strong>on</strong> library. The GNU Classpath project aims to be a Free Software replacementfor the JRE API JAR file. As such, it is meant to be a library of Java bytecodes that may be usedas a drop-in replacement in any Java runtime envir<strong>on</strong>ment. For our discussi<strong>on</strong>, we will assumeyou are using libgcj as shipped with gcj itself.10. http://gcc.gnu.org/java/jdk14-libgcj.html

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!