s i s t e m a o p e r a c i o n a l m a g n u x l i n u x | ~/ · documentação · suporte · sobre |
Next
Previous
Contents
2. How to Setup the Java Development Kit
There are several Java Development Kits available for Linux. These include:
If you are going to try just one JDK, I suggest you initially try the Sun J2SE, unless you are recommended otherwise by specific software you are using or want to use. Additionally, if you are interested in an open source implementation, you will need to use Kaffe. 2.1 Blackdown JDK
Background
The Blackdown JDK is a port of Sun JDK to Linux. As of the time of this writing, the Blackdown JDK is current with JDK 1.2.2 on the Intel architecture and 1.1.8 on the PowerPC. In December 1999, Sun announced availability of the Java 2 Platform, Standard Endition (J2SE) on Linux. This Sun release has significant impact on Blackdown because Blackdown is a port. In a press release, Sun states, "This week's announcement would not have been possible without the collaboration of Blackdown, a group of developers and enthusiasts around the globe. Since its inception, Blackdown has been a provider of Java technology for the Linux platform. Their dedicated effort over a number of years has laid the foundation for this release of the Java 2 platform port to Linux; in particular their effort was critical to the success of this release." Additionally, the Sun press release continues, "Blackdown.org continues to be a valuable source for Java technology for Linux, including JDK 1.1.x releases." Download
The Blackdown JDK can be obtained from http://www.blackdown.org. >From the Blackdown home page, select download and a mirror site. Select the version of the JDK you want. If other software that you are wanting to use does not recommend a specific version, I suggest the most current, which is at the time of this writing, JDK 1.2.2. Select the machine architecture you are installing on. For Intel architecture, select i386. Select the release candidate you want. If other software that you are wanting to use does not recommend a specific release candidate, I suggest the most recent or final version if available. For the Blackdown JDK, there are possibly a number of different files available in different packaging formats. Additionally you have to be sure you get support for the right libc for your Linux distribution. The files available include:
I suggest downloading only the jdk for Java development in English. When downloading the Blackdown files, you may need to select between libc5 and glibc as well as potentially a specific version of glibc. The libc options include:
If you are using a newer distribution of Linux, you will most likely have glibc. I suggest initially trying glibc. Installation
I suggest installing files in the /usr/local directory. After downloading the files, run: mkdir /usr/local/blackdown mv jdk* /usr/local/blackdown If you downloaded the tarball format, run: tar zxvf [filename].tar.gz Where [filename] is the name of the file. Under the /usr/local/blackdown directory, you now should see a directory such as jdk1.2.2. The above example shows JDK 1.2.2 release candidate 3 for the Intel architecture. Substitute the file name, version number, release candidate number, and architecture as appropriate. You will need to open each distribution package file in the above manner. Setting up Your Environment
The environment variables to set up are:
The JAVA_HOME environment variable references the home directory of your JDK installation. Set your JAVA_HOME environment variable to the directory into which you just installed a version of the Blackdown JDK. export JAVA_HOME=/usr/local/blackdown/jdk1.2.2 The $JAVA_HOME/bin directory has the Java compiler (javac) and the Java Virtual Machine (java) as well as other necessary programs for development. Add $JAVA_HOME/bin to your PATH. export PATH=$JAVA_HOME/bin:$PATH Note that $JAVA_HOME/bin was added to the front of the PATH so that the installed JDK will be used rather than any JDK that might have come with your Linux distribution. To confirm that your PATH is correctly set up, check which Java compiler and JVM will be used. which javac which java The output should reference javac and java in your $JAVA_HOME/bin directory. The CLASSPATH environment variable references all JARs and directories that you will need to compile and run Java programs. For JDK 1.2.2, you don't need to initially add any JARs to your CLASSPATH. JARs can be packaged in either .jar or .zip files. export CLASSPATH=$CLASSPATH:. Confirming Your Installation
You are now ready to compile and run a simple application. Create the following program. class HelloWorld { public static void main (String[] args) { System.out.println("Hello, World!"); } } Compile the program with the Java compiler. javac HelloWorld.java If the compiler produces errors, double check the syntax and confirm your PATH and CLASSPATH. Run the program with the JVM. java HelloWorld If the JVM produces errors, confirm your PATH and CLASSPATH. You should see the following output: Hello, World! Congratulations, you have installed, set up an environment for, and tested the Blackdown JDK on Linux. More Information
For more information on the Blackdown JDK, see the Blackdown website at http://www.blackdown.org. There is an excellent FAQ available. 2.2 IBM Java Developer Kit
Background
The IBM Java Developer Kit and Runtime Environment pass Sun's Java compatibility test and include the latest maintenance. (From the IBM website.) As of the time of this writing, the IBM Java Developer Kit is current with JDK 1.1.8 and is available only on the Intel architecture. Download
The IBM Java Developer Kit can be obtained from http://www.ibm.com/java/jdk/118/linux.
In order to download, you will have to register with the IBM website and agree to the license online. The files available include:
Since you will be doing Java development, I suggest downloading the ibm-jdk tarball file. Installation
I suggest installing files in the /usr/local directory. After downloading the files, run: mkdir /usr/local/ibm mv ibm-jdk-l118-linux-x86.tgz /usr/local/ibm You can now open the distribution package. To do this, type: tar zxvf ibm-jdk-l118-linux-x86.tgz Under the /usr/local/ibm directory, you now should see the jdk118 directory.
The above example shows JDK 1.1.8 for the Intel architecture. Substitute the filenames as appropriate. Setting up Your Environment
The environment variables to set up are:
The JAVA_HOME environment variable references the home directory of your JDK installation. Set your JAVA_HOME environment variable to the directory into which you just installed a version of the IBM Java Developer Kit. export JAVA_HOME=/usr/local/ibm/jdk118 The $JAVA_HOME/bin directory has the Java compiler (javac) and the Java Virtual Machine (java) as well as other necessary programs for development. Add $JAVA_HOME/bin to your PATH. export PATH=$JAVA_HOME/bin:$PATH Note that $JAVA_HOME/bin was added to the front of the PATH so that the installed JDK will be used rather than any JDK that might have come with your Linux distribution. To confirm that your PATH is correctly set up, check which Java compiler and JVM will be used. which javac which java The output should reference javac and java in your $JAVA_HOME/bin directory. The CLASSPATH environment variable references all JARs and directories that you will need to compile and run Java programs. Initially I suggest adding the following JARs to your CLASSPATH. JARs can be packaged in either .jar or .zip files. For instance: export CLASSPATH=$JAVA_HOME/lib/classes.zip export CLASSPATH=$CLASSPATH:. Confirming Your Installation
You are now ready to compile and run a simple application. Create the following program. class HelloWorld { public static void main (String[] args) { System.out.println("Hello, World!"); } } Compile the program with the Java compiler. javac HelloWorld.java If the compiler produces errors, double check the syntax and confirm your PATH and CLASSPATH. Run the program with the JVM. java HelloWorld If the JVM produces errors, confirm your PATH and CLASSPATH. You should see the following output: Hello, World! Congratulations, you have installed, set up an environment for, and tested the IBM Java Developer Kit on Linux. More Information
For more information on the IBM Java Developer Kit, see the IBM Java website at http://www.ibm.com/java.
2.3 Kaffe
Background
Kaffe is a cleanroom, open source implmentation of a Java Virtual Machine and class libraries. As of the time of this writing, Kaffe "mostly complies with JDK 1.1, except for a few missing parts." And "parts of it are already JDK 1.2 (Java 2) compatible." (From the Kaffe website.)
Kaffe may have already been shipped with your Linux distribution because of its open source license. Download and Installation
Rather than downloading from Kaffe, I suggest you initially try the Kaffe that most likely came with your Linux distribution. Alternatively, Kaffe can be obtained from http://www.kaffe.org. >From the Kaffe home page, select the current release. At the time of this writing, the current release is 1.0.5. The Kaffe version number has no relationship to JDK specification version numbers. Setting up Your Environment
The environment variables to set up are:
To confirm that your PATH is correctly set up, check which Java compiler and JVM will be used. which javac which java The CLASSPATH environment variable references all JARs and directories that you will need to compile and run Java programs. Initially I suggest you add the following JARs to your CLASSPATH. JARs can be packaged in either .jar or .zip files. For instance: export CLASSPATH=/usr/local/share/kaffe/Klasses.zip export CLASSPATH=$CLASSPATH:. Confirming Your Installation
You are now ready to compile and run a simple application. Create the following program. class HelloWorld { public static void main (String[] args) { System.out.println("Hello, World!"); } } Compile the program with the Java compiler. javac HelloWorld.java If the compiler produces errors, double check the syntax and confirm your PATH and CLASSPATH. Run the program with the JVM. java HelloWorld If the JVM produces errors, confirm your PATH and CLASSPATH. You should see the following output: Hello, World! Congratulations, you have installed, set up an environment for, and tested Kaffe on Linux. More Information
For more information on Kaffe, see the Kaffe website at http://www.kaffe.org. 2.4 Sun J2SE
Background
The Sun Java 2, Standard Edition (J2SE) is Sun's production release of the Java 2 Platform for the Linux operating system. As of the time of this writing, J2SE is current with JDK 1.2.2 on the Intel architecture. Download
J2SE can be obtained from http://developer.java.sun.com/developer/earlyAccess/j2sdk122.
You will need to register with Sun and agree to the license online before downloading. Installation
I suggest installing files in the /usr/local directory. After downloading the files, run: mkdir /usr/local/sun mv jdk1_2_2rc1-linux-i386.tar.gz /usr/local/sun You can now open the distribution package. To do this, type: tar zxvf jdk1_2_2rc1-linux-i386.tar.gz Under the /usr/local/sun directory, you now should see the jdk1.2.2 directory.
The above example shows JDK 1.2.2 release candidate 1 for the Intel architecture. Substitute the filenames as appropriate. Setting up Your Environment
The environment variables to set up are:
The JAVA_HOME environment variable references the home directory of your JDK installation. Set your JAVA_HOME environment variable to the directory into which you just installed a version of J2SE. export JAVA_HOME=/usr/local/sun/jdk1.2.2 The $JAVA_HOME/bin directory has the Java compiler (javac) and the Java Virtual Machine (java) as well as other necessary programs for development. Add $JAVA_HOME/bin to your PATH. export PATH=$JAVA_HOME/bin:$PATH Note that $JAVA_HOME/bin was added to the front of the PATH so that the installed JDK will be used rather than any JDK that might have come with your Linux distribution. To confirm that your PATH is correctly set up, check which Java compiler and JVM will be used. which javac which java The output should reference javac and java in your $JAVA_HOME/bin directory. The CLASSPATH environment variable references all JARs and directories that you will need to compile and run Java programs. For JDK 1.2.2, you don't need to initially add any JARs to your CLASSPATH. JARs can be packaged in either .jar or .zip files. export CLASSPATH=$CLASSPATH:. Confirming Your Installation
You are now ready to compile and run a simple application. Create the following program. class HelloWorld { public static void main (String[] args) { System.out.println("Hello, World!"); } } Compile the program with the Java compiler. javac HelloWorld.java If the compiler produces errors, double check the syntax and confirm your PATH and CLASSPATH. Run the program with the JVM. java HelloWorld If the JVM produces errors, confirm your PATH and CLASSPATH. You should see the following output: Hello, World! Congratulations, you have installed, set up an environment for, and tested the Sun J2SE for Linux. More Information
For more information on Sun J2SE, see the Sun Java website at http://java.sun.com. There are excellent discussion forums available where you might be able to find answers to various questions. Next Previous Contents |