LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices

Reply
 
Search this Thread
Old 05-10-2006, 11:13 PM   #1
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Rep: Reputation: 60
Installing Java on Debian ... Mini Howto


Installing Java is one of those things that we do only once in a great while, and, if you're like me, you always need to go looking for instructions on how to do it. The best set of such instructions has always been here, but for some reason there is now a glitch on the page that means the commands are not being printed. I mananged to put the commands back together from several sources, and I think it deserves to be here where I can find it when I need it.

First get rid of any java version you may have already installed. Run the command
Code:
$ java -version
If it finds anything, get rid of the old one. Some installations come with a crippled version of java which doesn't necessarily identify itself clearly. It might be named gij-4.0 or something else. Using 'locate java' may help you identify it's real name.

1. Get the Sun .bin file.
It's available here, or someplace nearby. You need the .bin file (not the .rpm) for either ix86 or amd64. Download it and put it in a working directory. Something like /home/yours/java makes sense.

2. Get "java-package".
You need the key application that makes this whole thing work, java-package. It's available in the 'contrib' section of your official Debian repo. Assuming that's on your /etc/apt/sources.list file, ...
Code:
# apt-get install java-package
That installation will include fakeroot, deb-helper, etc., if you don't already have them.

3. Create the .deb Package File.
cd to the working directory you created in step 1, and (as a regular user) ...
Code:
$ fakeroot make-jpkg jre-1_5_0_06-linux-i586.bin
Of course, your downloaded file name may differ somewhat from mine. Get it right, Tab Completion is your friend.

Sun may force you to bow to their omniscience by making you agree to something important to them during the unpacking process. Humor them. There will probably be some warnings during the two minute (+ or -) process of package building, but as long as it all ends the a message stating that the Debian package was successfully created, those messages are inconsequential.

4. Install the Java .deb Package.
Now you have to be root, so stay in the working directory, su, enter password, and ...
Code:
# dpkg -i sun-j2re1.5_1.5.0+update06_i386.deb
Again, if your package name doesn't quite match mine, get it right.

5. Check that it works.
This should be easy, unless it's not. As both root and a regular user run the command $ java -version The response should be something close to:
Code:
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_06-b05, mixed mode)
Notice how the version numbers match those of my .bin and .deb packages above. If yours don't, you have another version of Java already installed. See paragraph 2.

(Brief Intermission) Most Java packages need to know where the Java VM is installed. They find this out through an environment variable called JAVA_HOME. All versions of Java you install, including the one you just finished, will be placed in /usr/lib with names like j2re1.5-sun. The next two steps create an alias (symlink) to that Java VM, and set up the JAVA_HOME variable at login. Find your java home directory (something like /usr/lib/j2re1.5-sun), and make sure you know it's name.

6. Create a soft link to the java home directory.
This step usually eliminates the need to link from the plugin library of programs like Firefox that need to know where java lives in order to find plugins. Assuming that the java package you have installed is the same as my example, ... as root ... create a soft link like this:
Code:
# ln -s /usr/lib/j2re1.5-sun /usr/lib/java
7. Add the Environment Variable to /etc/profile
Using vim (if you're a manly man) or another text editor, open /etc/profile and look at or near the bottom. You should see a couple lines like this:
Code:
.
.
.
export PATH

umask 022
Change it to look like this:
Code:
export PATH

JAVA_HOME="/usr/lib/java"
export JAVA_HOME

umask 022
That's it ... reboot the machine, and Java should be working.

Last edited by rickh; 12-22-2006 at 12:47 PM.
 
Old 05-11-2006, 11:17 AM   #2
craigevil
Senior Member
 
Registered: Apr 2005
Location: OZ
Distribution: Debian Sid
Posts: 4,732
Blog Entries: 12

Rep: Reputation: 456Reputation: 456Reputation: 456Reputation: 456Reputation: 456
Wow all those steps? I can't help ask why?

All I have ever had to do is:

In Debian I found the easiest way to install Sun Java is to:
Add the following to your sources.list:
#Debian Unofficial
deb http://ftp.debian-unofficial.org/debian/ sarge main contrib non-free restricted
deb-src http://ftp.debian-unofficial.org/debian/ sarge main contrib non-free restricted
Then use Synaptic to search for the current Sun jre-binary. Select and apply. Java and the plugin for Mozilla/Firefox automatically install.

Why all the complicated steps when Synaptic or Apt-get take care of all that for you? That is the beauty of running a Debian system. Heck I have had 3 or 4 versions at one time with no problems, even had Blackdown and Sun both installed at one time.
 
Old 05-11-2006, 11:41 AM   #3
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Original Poster
Rep: Reputation: 60
lol. OK. Next time I install, I'll try your way. Mine works, tho.

I have been vaguely aware of debian-unofficial, but never used it. I'll put it on my sources list now.
 
Old 05-11-2006, 03:29 PM   #4
craigevil
Senior Member
 
Registered: Apr 2005
Location: OZ
Distribution: Debian Sid
Posts: 4,732
Blog Entries: 12

Rep: Reputation: 456Reputation: 456Reputation: 456Reputation: 456Reputation: 456
I wasn't trying to say your way was bad. I apologize if I came off as that way.

Its just that using Synaptic/Apt-get properly will save you many steps with a lot of apps, not just Java. Same goes for most broswer plugins like Mplayer, Flash, Realplayer, Adobe. Even wine installs very easily with Synaptic. It's all a matter of having the things you need in your sources.list.

Your way will most likely help quite a few people that run into trouble. It is a lot more detailed than I possible could have done. Keep up the good work.
 
Old 05-16-2006, 04:12 AM   #5
Dead Parrot
Senior Member
 
Registered: Mar 2004
Distribution: Debian GNU/kFreeBSD
Posts: 1,597

Rep: Reputation: 46
It looks like Sun's java will be soon added to the "non-free" section of the official Debian package repositories.

http://www.desktoplinux.com/news/NS6957752431.html

Last edited by Dead Parrot; 05-16-2006 at 04:13 AM.
 
Old 05-17-2006, 08:05 AM   #6
Dead Parrot
Senior Member
 
Registered: Mar 2004
Distribution: Debian GNU/kFreeBSD
Posts: 1,597

Rep: Reputation: 46
Well, well, what do you know! It's already there. Swift action from the Debian packagers.

http://packages.debian.org/cgi-bin/s...ll&release=all
 
Old 05-17-2006, 12:55 PM   #7
craigevil
Senior Member
 
Registered: Apr 2005
Location: OZ
Distribution: Debian Sid
Posts: 4,732
Blog Entries: 12

Rep: Reputation: 456Reputation: 456Reputation: 456Reputation: 456Reputation: 456
Quote:
Originally Posted by Dead Parrot
Well, well, what do you know! It's already there. Swift action from the Debian packagers.

http://packages.debian.org/cgi-bin/s...ll&release=all
Cool that makes it even easier. For now it looks like it is only in unstable.
 
Old 05-20-2006, 07:21 AM   #8
porschemad911
LQ Newbie
 
Registered: Mar 2006
Location: Canberra, Australia
Distribution: Debian Sarge
Posts: 9

Rep: Reputation: 0
I know this is very un-Debianlike, but I just extract the Sun JDK into my ~/Programs/jdkxxx folder, then just add the appropriate folder to my path (hmmm ... perhaps they should really be in /usr/local/bin), and create symlinks in ~/.mozilla/plugins (for JRE).

But then, I have many apps installed in ~/Programs. It's like my own little package management system I guess. I just like to do it this way because it isn't touching the system, just my own setup. And I can upgrade and remove apps at will, *knowing* nothing is left behind. I still haven't got to the point of *completely* trusting apt-get uninstalls yet (a hangover from my Window's days).

I also like configuring stuff manually too, eg flash, Adobe, firefox, thunderbird etc. For me, Debian Sarge is just a very reliable, stable base system to install a bare-bones XFCE desktop with only the apps I want. And for me, it works absolutely brilliantly!

Of course this also isn't useful for a multi-user PC, which mine is not.
 
Old 05-22-2006, 09:25 PM   #9
johnMG
Member
 
Registered: Jul 2003
Location: CT, USA
Distribution: Debian Sarge (server), Etch (work/home)
Posts: 601

Rep: Reputation: 31
If I absolutely need it (for work), I download the official Sun install binary and install it into /opt. Their directions are pretty straightforward.

On my system, /opt is where big standalone-type stuff often goes when it's not part of a debian package, or for some reason I don't want to use a debian package.

Small stuff built by-hand often lands in /usr/local, but some machines may have an /opt/local for this instead.
 
Old 05-26-2006, 05:10 AM   #10
jeweldu
LQ Newbie
 
Registered: May 2006
Posts: 2

Rep: Reputation: 0
Your plugin link concept is great. Thanks...
 
Old 05-28-2006, 06:26 PM   #11
mariogarcia
Member
 
Registered: Sep 2005
Distribution: debian, solaris 10
Posts: 192

Rep: Reputation: 31
hello i tried the method on the mini howto
and i get this message :
"make: the `-j' option requires a positive integral argument"
then a list of option of make.
what's wrong?
thank you.
about the other methods; is it possible to have a mini howto as well, or an extensive howto is even better,
thanks in advance.
mario
 
Old 05-29-2006, 08:16 AM   #12
jeweldu
LQ Newbie
 
Registered: May 2006
Posts: 2

Rep: Reputation: 0
So far I have solved the proble by using 2 steps in Fedora RedHat:
1) For plugins:
cd \usr\lib\mozilla\plugins
ln -s /usr/java/jdk1.5.0_06/jre/plugin/i386/ns7/libjavaplugin_oji.so ./libjavaplugin_oji.so

2) For Path:

By editing the /etc/profile file in the following way:

# Path manipulation
if [ $EUID = 0 ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin

#This line is added by me
pathmunge /usr/java/jdk1.5.0_06/bin

fi
 
Old 06-15-2006, 09:35 AM   #13
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Original Poster
Rep: Reputation: 60
OK. Update. I was mildly embarrassed at very reasonable suggestions that my method was unnecessarily complicated, then Debian made it even worse by very publically adding Sun Java to their official repos. I am now in the process of setting up a new 32-bit system, so I had the opportunity to do it the easy way.

I feel better now. The easy way blew up in my face, but the old tried and true method outlined above worked again.

My problems, briefly, involved the fact that installing Sun Java from the repos did not delete the gij.4.1 java that came with the Debian desktop installation. Open Office and other programs were also thoroughly integrated with that app. Firefox didn't handle java applets correctly, and when I tried to use 'java -jar filename.jar' to execute a java program, it also didn't work. A large part of those problems seemed to be related to /etc/profile not including the JAVA_HOME variable.

In checking for java installations, I found, what appeared to be, two separate identical directories in /usr/lib/jvm/ ... One named something like sun-java5-1.5.0 and another named sun-java-1.5.0-06. (Those are probably not exactly right, but something close.)

When I went to purge all that stuff including gij, aptitude took OpenOffice as well. No problem ... I got the Sun .bin file, built and installed the .deb, edited /etc/profile, and voila!, everything worked. No need for Mozilla plugins or any of that foolishness.

Now I just have to reinstall OpenOffice, which previous experience tells me will like Sun Java as well as it did gij. In the process, I also found that Sun had an updated version, for whatever that's worth.

Easy is fine, but I'm an old man. Sometimes it's easier to stick with the devil I know.

Last edited by rickh; 06-15-2006 at 09:38 AM.
 
Old 07-18-2007, 08:58 PM   #14
luis14
Member
 
Registered: Jun 2006
Location: Des Moines
Distribution: Debian Lenny
Posts: 59

Rep: Reputation: 15
This mini tutorial has always served me well (thanks rickh!), but I've run into a problem trying to install Java using jre-6u2-linux-i586.bin

when I run fakeroot make-jpkg I get this error:
Code:
daniel@8400-debian:~/java$ fakeroot make-jpkg jre-6u2-linux-i586.bin
Creating temporary directory: /tmp/make-jpkg.LInXag5703
Loading plugins: blackdown-j2re.sh blackdown-j2sdk.sh common.sh ibm-j2re.sh ibm-j2sdk.sh j2re.sh j2sdk-doc.sh j2sdk.sh j2se.sh sun-j2re.sh sun-j2sdk-doc.sh sun-j2sdk.sh

Detected Debian build architecture: i386
Detected Debian GNU type: i486-linux-gnu

No matching plugin was found.
Removing temporary directory: done
daniel@8400-debian:~/java$
Do I have the wrong bin file? Did Sun change the package?
Would prefer not using apt to install java as it depends on iceweasel and several other packages I don't need.
 
Old 07-18-2007, 09:36 PM   #15
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Original Poster
Rep: Reputation: 60
Actually, I have decided this howto is obsolete since the Debian repo packages are now so well supported. I have never used the blackdown packages, so I can't speak for them. The Testing Repos have Sun Java6 version 6-00-2. I think Sid has 6-01-1, but only for the i386 arch. I would recommend one of those, but since the Debian package stores the files in different directories, when you're finished, you may need to use "# update-alternatives --config java" to actually get it working. I would also remove the line from this howto in your /etc/profile

The changeover from the old way to the new is not as clean as one might hope, but I think it's worth it. As far as I know it doesn't carry any dependencies of it's own, but some programs already installed that depend on java may be affected.

Last edited by rickh; 07-18-2007 at 09:38 PM.
 
  


Reply

Tags
apt, debian, environment, get, home, howto, instructions, java, javapackage, variable


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HOWTO: Installing nVidia Graphics Drivers on Debian Etch MrKrrtft Debian 1 12-27-2005 02:04 AM
Java on Debian - Nebie HOWTO rikkulinux Debian 5 10-17-2003 01:32 AM
Java on Debian - Nebie HOWTO rikkulinux Programming 6 10-15-2003 08:05 PM
Apt howto installing software for debian monkeymartin Debian 7 08-20-2003 05:18 AM
installing mplayer and skins on debian woody | howto macewan Linux - Software 2 03-04-2003 06:36 AM


All times are GMT -5. The time now is 04:25 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration