|
1
|
Download
the Java software from the Sun site. See to it that you
download the version for Linux platform and not the Windows
one. Most probably you would get the software as a tarball
(.tgz). If you get it as an Windows Executable (.exe)
file then you got the wrong one. |
|
2
|
You
can install Java in any directory. But if you want all the
users to access Java then it is better to install it under
the /usr/local directory. |
|
3
|
I
shall explain a simple way where you would extract the files
from the tarball and then copy them to the /usr/local directory.
Type the following command to extract the files from the
original tarball
gunzip -dc jdk.x.x.x.tgz | tar xf -
|
|
5
|
This
would extract all the files into a directory named jdk.x.x.x
in the same parent directory that had the original tarball.
|
|
6
|
Copy
this entire directory into the /usr/local directory.
So you would finally have a structure as /usr/local/jdk1.2.2
|
|
7
|
Check
that the jdkx.x.x directory has a /bin , /lib and a few
other folders inside it. |
|
8
|
Finally
you got to add these executables (namely java, javac) to
your path. Else you would have to give the absolute path
every time you want to use these executables. |
|
9
|
Edit
the /HOME/.bash_profile file and make suitable changes
to the path variable in it
PATH=/usr/local/jdkx.x.x./bin/:$PATH
|
|
10
|
Once
you save the file then execute the file by typing the following
. $HOME/.bash_profile
|
|
11
|
Once
this is over you can use your normal editor (Emacs is what
I use) to write your Java programs and then simply type
the following to compile and then run your program
# To compile your program
javac Myprogram.java
# To execute the program
java Myprogram |