Working with Java Applications


For a full-featured web experience, and in order to use many cross-platform applications, you'll likely want to install Java. This "virtual machine" programming environment created by and licensed from Sun Microsystems is distributed free of charge through the FreeBSD Foundation website (http://www.freebsdfoundation.org/downloads/java.shtml) and can be installed using the pkg_add command after downloading each appropriate file, as follows:

# pkg_add diablo-jdk-freebsd6-1.5.0.06.00.tbz # pkg_add diablo-jre-freebsd6-1.5.0.06.00.tbz


The FreeBSD ports collection includes a whole java category full of applications and programming utilities that you can use within the Java environment that results from this installation, and web pages that include Java programs will work as intended.

As of this writing, the latest stable release of the Java Development Kit (JDK) and Java Runtime Library for FreeBSD is 1.5. If you need earlier versions (for compatibility, for example), you can install the ports named jdk15 (or jdk14 or jdk13), which predate the official license agreement between the FreeBSD Foundation and Sun, and therefore are based on a much more cumbersome installation procedure than is possible with the official JDK/JRE 1.5 release. Most users will want to stick with the official licensed software from the FreeBSD Foundation rather than mess with the earlier ports.

Note

The Java compiler is itself written in Java, making it possible for you to write Java applications on any platform that has the JDK/JRE installed on it, including FreeBSD.


Installing Java Applications

Many Java applications aren't included in the ports collection. However, because Java applications by their very nature are portable and binary-compatible, you can install and run in FreeBSD any application written in Java, without having to compile it. Installation procedures vary depending on the application, so refer to the README files and other documentation that came with the application for instructions.

Java applications sometimes come as compressed Java archives. These archives have a .jar extension. You can uncompress Java archives by typing java -jar followed by the name of the compressed file.

Running Java Applications

Java applications need to be run with the aid of the Java Runtime Engine. To start a Java application, invoke the java program followed by the name of a Java class file. Many applications contain multiple class files, but the documentation that comes with the application will tell you which class file to start. Java class files have a .class extension.

Sometimes Java applications come in a compressed format. These applications can be run in their compressed form and uncompressed on the fly. In this situation, the Java interpreter should be invoked with the -jar option.

Note

A detailed discussion of Java is beyond the scope of this book. For more information on Java, visit the Java website at http://java.sun.com. If you are interested in learning Java programming, many good books are available on the market today, including Sams Teach Yourself Java 2 in 21 Days.





FreeBSD 6 Unleashed
FreeBSD 6 Unleashed
ISBN: 0672328755
EAN: 2147483647
Year: 2006
Pages: 355
Authors: Brian Tiemann

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net