Java Reference
In-Depth Information
6.2
U SE L INUX F EATURES TO M AKE M ULTIPLE J AVA SDK S
P LAY N ICELY T OGETHER
We did not spend much time discussing the installation of Java on your Linux
system in previous chapter. In fact, we did not discuss it at all. This is because
the installation instructions that come with the SDK are more than adequate
if you wish only to install a single Java SDK. But what if you want to install,
say, both the Sun Java SDK and the IBM Java SDK? Then things get a bit more
interesting.
We're going to review the concept of filesystem links, and how they work
on Linux. While it may seem odd to discuss them here, we'll be using links to
switch gracefully between different Java installations. Links are a powerful
feature in Linux filesystems, and switching SDKs is a good application thereof.
If you're already familiar with links, skip ahead to Section 6.2.2.
6.2.1
A link is simply a name attached to a collection of data—that is, to a file. In
other words, every file has one set of data and at least one link (a name). But a
file may have more than one link. In other words, two different filenames may
point to the same data. When you do this, you appear to have two copies of
the file, but a change to one also changes the other. Deleting one, however,
does not delete the other. It merely deletes the link. The file itself is only
deleted when the last link is gone.
Links
6.2.1.1
Links come in two flavors: hard and symbolic. A hard link looks like a file in
and of itself. Let's show you a hard link, before and after.
Hard Links
$ ls -la
total 12
drwxrwxr-x 2 mschwarz mschwarz 4096 Jul 8 10:11 .
drwx------ 50 mschwarz mschwarz 4096 Jul 8 10:11 ..
-rw-rw-r-- 1 mschwarz mschwarz 45 Jul 8 10:11 sample
$ cat sample
This is a sample
file to demonstrate
links.
$
Search WWH ::




Custom Search