On Sun, 9 Feb 2003, Julian Templeman wrote:

> OK... now I've got 9.0 working, time to do something with it!
> 
> I need Java on here, so I've downloaded the .bin distribution from
> Sun. Since I'm still a Clueless Newbie at this stage, I want advice on
> the best place to install it... On a Windows machine I'd just install
> it any-dam-where and add the directory to the path. Is this the
> recommended way on Linux, or should the Java folder tree live
> somewhere in particular?
> 
> Thanks!
> 
> julian
> 
> Templeman Consulting Ltd.
> London and North Wales

Hi Julian,

The attached howto should get you going in the right direction. I use Java 
on my system for program development and this is how I've installed JDK on 
my system. 

-- 
Mark

"If necessity is the mother of invention, then who's the father?"
-----------------------------------------------------------
Paid for by Penguins against modern appliances(R)
Linux User Since 1996
Powered by Mandrake Linux 8.2 & 9.0
ICQ# 27816299
Installing JDK from Sun HOWTO

Installing Java from Sun, found at http://java.sun.com is an easy
task and doesn't need to be, nor should it be seen as a terribly
hard thing to do. Here are the steps to take in order to make this
happen.



OBTAINING THE PACKAGES FOR INSTALLATION:

1. Point your browser to the URL above at the Sun site, download
   the packages you need.
        a. if you're a Java developer, or a beginning Java programmer
           then all you're going to need is the JDK package.
                http://java.sun.com/j2se/1.4.1/download.html
        b. if you do have a need for both the JDK and JRE packages
           you can get both packages from the same place. How to accomplish
                this will become self-evident once you're there and see how
                things work.
        c. if you don't know whether or not you need both, then it's very
           likely you don't and should just download the JDK package.

        The links for downloading JDK=(SDK) or JRE are clearly marked and
        easily and quickly visible. For Linux there are two types of files
        you can download. Personally I feel the "Linux Self extracting" file
        is the easiest to work with. You can also download the RPM self
        extracting file if you want to install JDK/JRE via the RPM method.
        However, there is a drawback to getting the RPM and doing the
        install that way.

        By getting the plain self-extracting package, you, the user have
        total control as to where it gets installed to. When I explain
        the actual installation of the package you'll see the more
        clearly why this method of installation is easier and less work.
        With the RPM installation you actually have to know more about what
        needs to be done in order for things to work correctly.
        

INSTALLING THE JDK/JRE PACKAGE:

 * Ok, assuming your download completed cleanly and successfully
   its time to start the installation. There isn't anything magical
        about getting this done. It's a simple and painless process. If you're
        a Mandrake Linux user and you're currently running version 8.2 or
        above, then it's likely you've already got a version of Java
        installed on your system that comes with and installs with the 
        system. This Java system will perform most things adequately enough
        for small tasks. However, it is limited in scope and functionality
        which is why you're probably reading this HOWTO right now. This is
        not to knock Mandrake or their preparaion of the system, but
        merely to mention that the Java version that ships with Mandrake
        8.2 and above is limited and can't do the things that Sun's package
        can and does.
        
        NOTE: In order to know for certain what version of Java may, or 
              may not exist on your system issue this command to find out
                        from the system what is installed on it:
                        
                           java -version
                        
                        You'll get one of three back from the system.
                        1. if it's a stock Mandrake install you'll see this returned
                           to the terminal;
                                
                                Kaffe Virtual Machine
            Copyright (c) 1996-2000
            Transvirtual Technologies, Inc.  All rights reserved
            Engine: Just-in-time v3   Version: 1.0.6   Java Version: 1.1

                                (again, for RedHat machines or other distros you can
                                try this, but I'm not sure exactly what you'll get
                                returned to the terminal. If you get something similar
                                then the steps below will work for you as well. this 
method
                                has been done successfully on both RedHat 8.0, 
Mandrake 8.2
                                and 9.0 systems.)
                                
                        2. If JDK is already installed on your system "correctly"
                           then this will be your system's response;
                                
                                java version "1.4.0_02"
            Java(TM) 2 Runtime Environment, 
                                Standard Edition (build 1.4.0_02-b02)
            Java HotSpot(TM) Client VM (build 1.4.0_02-b02, mixed mode)
                                
                        3. non-Mandrake systems such as RedHat, SuSE or others
                           the system output is unknown at this time, however I dare
                                say that it will likely be very similar. If anyone 
reading
                                this knows the correct answer please feel free to send
                                that information in and I'll add it to this document.

        At this time I can't really speak to what comes with some of the other
        main Linux distros since I personally am a Mandrake user through
        and through, although I have been known to roll a RedHat installation
        around here and there. And, indeed at the moment I've got RedHat 8.0
        installed on the same box that Mandrake lives on. I can tell you
        that in order to compile and run programs written in Java for
        myself and for school I've had to install Sun's JDK on my RedHat
        system as well as on my XP and Mandrake installations. Enough of this
        though...lets get down to business...

        UNPACKING THE PACKAGE:

        1. Enter the directory where you saved the downloaded file(s) to.
        2. Chmod the file to 755 so that it's executable.
           NOTE: you don't have to be root to perform this, but it doesn't
                      to be root since for the following steps you "will" have
                                to be root.
        3. After you've chmod'd the package you need to execute the file
           in order to extract the files for the Java installation.
                a. in a terminal window issue this command:
                   ./j2sdk-1_4_1_01-linux-i586.bin [enter] <-- means hit ENTER key
                        At this point the file will begin extracting the Java
                        installation from downloaded file. At the bottom left corner
                        of the terminal window you'll see a --[MORE]-- prompt. Hit
                        the space bar to advance the screen. This is the user license
                        agreement that is scrolling by in the terminal as you hit the
                        SPACE bar. At the end of the screen you'll be asked to input
                        either "yes" or "no". Of course if you wish for the Extraction
                        to continue your answer will be "yes".
                b. After the process terminates there will be a new directory
                   where you downloaded and executed the file named
         j2sdk-1_4_1_01-linux-i586.bin. The folder name should be
         j2sdk-1_4_1_01. You can, at this point rename the folder anything
                        you like, however giving the folder a meaningful name
                        according to it's use on your system is a good idea. I've
                        named mine JDK.
                        
   PREPARING YOUR SYSTEM FOR INSTALLATION:
        
        Now it's necessary to make your system ready for the installation of the
        JDK package. The installation for JRE is identical with a few minor 
        differences that will be clear in a moment.
        
        1. As root user open your favorite filemanager and navigate to /usr/bin.
           If you're predisposed to using a GUI filemanager thats fine. If you're
                a die-hard terminal type, thats OK too. cd into the /usr/bin 
directory.
        
        2. In a terminal window as root user issue this command to create a 
           new directory in /usr. The directory's name should be "java".

        3. Copy the directory that was extracted from, and renamed to something
           meaningfull, from the downloaded Java archive and ALL it's contents 
                into the new directory you've just created, "/usr/java" in /usr. As
                I mentioned above I renamed mine JDK. So, when I copied the folder
                and files to /usr/java the resulting tree appears like this:
                
                      /usr/java/JDK/    <--{folder with files that gets copied}
                                              bin/
                                                                  demo/
                                                                  include/
                                                                  jre/
                                                                  lib/
                                                                  man/
                                                                  COPYRIGHT
                                                                  LICENSE
                                                                  README
                                                                  README.html
                                                                  src.zip

   4. Locate the following list of files in /usr/bin. They are executable
           bash scripts:

                   jar
                   java
                   javac
                   javadoc
                   javakey
                   javap
                   jdb

        5. Select them all by pressing down and holding the CTRL key.
        6. Now, once all the files have been selected hit the DELETE key on your 
           keyboard. Yes...thats right...I said the DELETE key. Since you're going 
                to be replacing these files with others that are taking over their 
                job they're no longer needed and are of no consequence. If you're a 
                bit squeemish about doing this you "could" do the safe thing and 
                rename them all by appending .old to the end of each of the file 
names,
                but this procedure has been repeatedly tested and is safe for Penguin 
                consumption.
   7. Now since you've gotten rid of the old java files from /usr/bin go to the 
      newly created directory where you installed JDK, and locate the JDK
      counterparts of the files you've just delete from /usr/bin. Use the list
      of files from this HOWTO if you're not able to remember exactly.
      The files you'll need are in /usr/bin/JDK/bin. Select all the only
      the files in that directory that you'll need to replace the one's
      you've removed from /usr/bin. You can select them all at once by
      holding down the CTRL key and then clicking on each file.
   8. Now drag the selected files to /usr/bin and drop them into /usr/bin.
      From the context menu in Konqueror choose "Link Here". Thats it!
      
   PERFORMING THIS FROM THE COMMAND LINE:
   
   This same procedure can be accomplised easily from the command line as well.
   Below are the steps for doing just that.
   
   1. remove the old java files from /usr/bin by issuing this command:
   
         cd /usr/bin   [enter]
         rm -vf jar java javac javadoc javakey javap jdb
         
   2. create new symlinks from /usr/java/JDK/bin to /usr/bin like so:
   
         ln -s /usr/java/JDK/bin/jar /usr/bin/jar
         ln -s /usr/java/JDK/bin/java /usr/bin/java
         ln -s /usr/java/JDK/bin/javac /usr/bin/javac
         ln -s /usr/java/JDK/bin/javadoc /usr/bin/javadoc
         ln -s /usr/java/JDK/bin/javakey /usr/bin/javakey
         ln -s /usr/java/JDK/bin/javap /usr/bin/javap
         ln -s /usr/java/JDK/bin/jdb /usr/bin/jdb
         
   And thats all there is to that. The procedure is done and you're ready to
   use JDK. As an added bonus for those who are "really" new to all this kind
   of stuff in Linux below is a bash script that will accomplish the same
   that I've detailed above. To make use of the script simply open your favorite
   text editor and copy and paste the code into an empty file, making sure
   to get "all" of it, save the file to the same directory that you've extracted
   the JDK files to, and chmod the script to 755.
                


Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Reply via email to