Chapter 5: Fixing Java and ANT
Java installation
Note that there are a lot of choices on what to download. What you want is the JDK 5.0 Update 6 or a newer version. You do not need the entire J2EE suite of tools.
Click to download the JDK and when prompted click to agree to license and then download the file. The file name should look something like this, depending on the version.
[root@nodeB ~]# ls -l jdk-1_5_0_06-linux-i586.bin
-rw-r--r-- 1 root root 48974825 Feb 20 11:13 jdk-1_5_0_06-linux-i586.bin
The md5 checksum for the file is:
[root@nodeB ~]# md5sum jdk-1_5_0_06-linux-i586.bin
3cdad4a383b93680f02f6f06198c2227 jdk-1_5_0_06-linux-i586.bin
Move the downloaded file to the /opt directory and make it executable:
[root@nodeB ~]# mv jdk-1_5_0_06-linux-i586.bin /opt/
[root@nodeB ~]# cd /opt/
[root@nodeB opt]# chmod 755 jdk-1_5_0_06-linux-i586.bin
You can run the file to unpack the binary installation into the directory:
[root@nodeB opt]# ./jdk-1_5_0_06-linux-i586.bin
You will need to page through license then answer 'yes' to accept the terms of license. After the distribution is unpacked the contents of the directory should look similar to this:
[root@nodeB opt]# ls -l /opt/jdk1.5.0_06/
total 17284 |
| drwxr-xr-x |
2 |
root |
root |
4096 |
Nov 10 16:19 |
bin |
| -r--r--r-- |
1 |
root |
root |
2487 |
Nov 10 15:38 |
COPYRIGHT |
| drwxr-xr-x |
8 |
root |
root |
4096 |
Nov 10 16:19 |
demo |
| drwxr-xr-x |
3 |
root |
root |
4096 |
Nov 10 16:19 |
include |
| drwxr-xr-x |
6 |
root |
root |
4096 |
Nov 10 16:19 |
jre |
| drwxr-xr-x |
2 |
root |
root |
4096 |
Feb 20 11:16 |
lib |
| -r--r--r-- |
1 |
root |
root |
15584 |
Nov 10 15:38 |
LICENSE |
| drwxr-xr-x |
4 |
root |
root |
4096 |
Nov 10 16:19 |
man |
| -r--r--r-- |
1 |
root |
root |
20415 |
Nov 10 15:38 |
README.html |
| drwxr-xr-x |
4 |
root |
root |
4096 |
Nov 10 16:19 |
sample |
| -rw-r--r-- |
1 |
root |
root |
17527615 |
Nov 10 15:38 |
src.zip |
| -r--r--r-- |
1 |
root |
root |
68419 |
Nov 10 15:38 |
THIRDPARTYLICENSEREADME.txt |
Test the installation by running the java virtual machine with the '-version' flag:
[root@nodeB opt]# /opt/jdk1.5.0_06/bin/java -version
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
Also test the java compiler:
[root@nodeB opt]# /opt/jdk1.5.0_06/bin/javac -version
javac 1.5.0_06
javac: no source files
Usage: javac <options> <source files>
where possible options include:
| -g |
Generate all debugging info |
| -g:none |
Generate no debugging info |
| -g:{lines,vars,source} |
Generate only some debugging info |
| -nowarn |
Generate no warnings |
| -verbose |
Output messages about what the compiler is doing |
| -deprecation |
Output source locations where deprecated APIs are used |
| -classpath <path> |
Specify where to find user class files |
| -cp <path> |
Specify where to find user class files |
| -sourcepath <path> |
Specify where to find input source files |
| -bootclasspath <path> |
Override location of bootstrap class files |
| -extdirs <dirs> |
Override location of installed extensions |
| -endorseddirs <dirs> |
Override location of endorsed standards path |
| -d <directory> |
Specify where to place generated class files |
| -encoding <encoding> |
Specify character encoding used by source files |
| -source <release> |
Provide source compatibility with specified release |
| -target <release> |
Generate class files for specific VM version |
| -version |
Version information |
| -help |
Print a synopsis of standard options |
| -X |
Print a synopsis of nonstandard options |
| -J<flag> |
Pass <flag> directly to the runtime system |
Lastly set up your environment to define JAVA_HOME and to put the java virtual machine and the java compiler on your path. The instructions below show how it is done from the command line, however, if you are logging off and on you might want to make sure this is set up via a profile file so it is automatically executed:
[root@nodeB ~]# export JAVA_HOME=/opt/jdk1.5.0_06
[root@nodeB ~]# export PATH=$JAVA_HOME/bin:$PATH
[root@nodeB ~]# which java
/opt/jdk1.5.0_06/bin/java
[root@nodeB ~]# which javac
/opt/jdk1.5.0_06/bin/javac
|