Posted by Steve on Tue 17 May 2005 at 17:50
Several popular tools require a Java runtime environment, or JRE, to work. Whilst there a growing number of open Java environments at times installing Sun Java environment is the pragmatic approach - unfortunately the software doesn't come in a Debian package. This short recipe shows how to install a Java SDK, or JDK, as a Debian package, and make it work inside your browser.
Whilst there is nothing wrong with installing software outside the control of the Debian packaging system, it's not something that should be undertaken lightly as it makes it hard to keep track of installations, and it complicates updating a number of machines from a centralised Debian package repository.
Thankfully there are facilities available which make it a simple job to install Sun's Java as a Debian package.
Two packages we're going to need are java-package, and fakeroot. These can be installed simply:
apt-get install fakeroot java-package
Once the relevent packages have been installed you will need to download the Sun release of the Java package from http://java.sun.com
At the time of writing the most current version can be found here:
Once you agreed to the license presented to you, and have downloaded the file you will have something like jre-1_5_0_03-linux-i586.bin.
To turn this into a Debian package you should run:
fakeroot make-jpkg jre-1_5_0_03-linux-i586.bin
This command will first prompt for confirmation, then :
(The name, and email address, you give will be inserted into the Debian package information - and not sent to Sun.)
Once these questions have been answered the process will inform you that your package has been built shortly afterwards. The final output you should expect to see will look something like this:
The Debian package has been created in the current directory. You can install the package as root (e.g. dpkg -i sun-j2re1.5_1.5.0+update03_i386.deb).
As the instructions tell you it is now possible for you to install the package by becoming root and running:
dpkg -i sun-j2re1.5_1.5.0+update03_i386.deb
One final step might be for you to ensure the Java software works for Mozilla Firefox, or the Mozilla browser.
The package you've installed should include a plugin for your browser. At the time of writing the most recent Sun Java version we've been using will install a plugin for you at the following location:
/usr/lib/j2re1.5-sun/plugin/i386/ns7/libjavaplugin_oji.so
Create a symlink to this directory in your home directory:
ln -s /usr/lib/j2re1.5-sun/plugin/i386/ns7/libjavaplugin_oji.so \ ~/.mozilla/plugins/
If you wish to do this for all users on the current system instead run, as root:
ln -s /usr/lib/j2re1.5-sun/plugin/i386/ns7/libjavaplugin_oji.so \ /usr/lib/mozilla/plugins/
(You might find that the plugin has been automatically installed for all users - so it's worth checking whether you need to complete this last step yourself.)
Thanks for pointing those out - I've updated the piece now to correct the mistakes.
Steve
-- Steve.org.uk
[ Parent ]
[ Parent ]
What's wrong with not using fakeroot? Nothing.
Ultimately you need to be root on the machine to install the package on it, so it's not a huge win to be able to do the build as a non-root user - you're just buying security in case there's a bug in the make-jpkg tool.
The idea of running the least amount of things as root as necessary is just a good habit to be in - which is probably why it's often recommended.
As to why your fakeroot build fails - hard to see without seeing what error messages you're getting. If it happens in the future it would be useful if you filed a bug about the problem.
Steve
-- Steve.org.uk
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
Thanks!
It is good to know that at least some of the articles apply to Ubuntu, but I guess it's not a huge suprise as most of the packages will be largely the same as Debian's original ones.
Might be worth having an Ubuntu related poll..?
Steve
-- Steve.org.uk
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
Sounds like you didn't run fakeroot.
Using alien would probably work but it's not supported, and not expected to work.
Try it and see?
Steve
-- Steve.org.uk
[ Parent ]
Nope just prefix the make-jpkg command with fakeroot as shown in the article and it should work - but you show errors like 'permission denied' which make me suspect you didn't do that.
Steve
-- Steve.org.uk
[ Parent ]
[ Parent ]
Having just downloaded jdk-1_5_0_04-linux-i586.bin to see if I can replicate your error I get the following error too:
Creating jdk1.5.0_04/jre/lib/deploy.jar mkdir: cannot create directory `/etc/.java': Permission denied mkdir: cannot create directory `/etc/.java/.systemPrefs': No such file or directory touch: cannot touch `/etc/.java/.systemPrefs/.system.lock': No such file or directoryDone. ... snip
The package is still built, although I don't know how well it will work.
Looking at the java-package bug list I see the following relevent bug entry:
So I guess you're not alone.
If you're in a hurry install the package and see how well it works, if you're not wait for it to be fixed in a new java-package version I guess.
Steve
-- Steve.org.uk
[ Parent ]
[ Parent ]
[ Parent ]
Strange, I just downloaded the latest version myself and tried to replicate this.
Whilst I do get some of the errors highlighted in previous comments, which look like this:
reating jre1.5.0_04/lib/deploy.jar mkdir: cannot create directory `/etc/.java': Permission denied mkdir: cannot create directory `/etc/.java/.systemPrefs': No such file or directory touch: cannot touch `/etc/.java/.systemPrefs/.system.lock': No such file or directory chmod: cannot access `/etc/.java/.systemPrefs/.system.lock': No such file or directory
The rest of the build, and the installation appears to work correctly.
I'm suspicious of the shared library error as that seems to be a non-java problem. Upon my host I see:
skx@mystery:~$ ls /usr/lib/libfakeroot* /usr/lib/libfakeroot.so.0 /usr/lib/libfakeroot-tcp.so.0 /usr/lib/libfakeroot-sysv.so.0 /usr/lib/libfakeroot-tcp.so.0.0.1 /usr/lib/libfakeroot-sysv.so.0.0.1 /usr/lib/libfakeroot: libfakeroot-sysv.so.0 libfakeroot-tcp.so.0 libfakeroot-sysv.so.0.0.1 libfakeroot-tcp.so.0.0.1
You say that you have libfakeroot.so.0 present. Is it fully installed? (ie. it is not a broken symlink or something silly like that?).
Finally I guess if everything is OK you should be able to test fakeroot by running the following:
skx@mystery:/tmp$ fakeroot /usr/bin/id uid=0(root) gid=0(root) groups=20(dialout),...1000(skx)
Does that work as expected?
Steve
-- Steve.org.uk
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
What is the error?
If it is that you don't have a specific package installed (to satisfy dependencies) then you might be out of luck unless you create a virtual/dummy package.
If it is something else we might be able to help.
(I admit I'm not familiar with the package you mention..)
Steve
-- Steve.org.uk
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
I'm sorry I have no experience with AMD64 - I think your best bet is to ask for assistance upon the debian-user mailing list.
Steve
--
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
I'm not sure I'm afraid.
Because I don't understand what you're meaning when you say "jsp pages" - that sounds more like a server-side technologoy. (Java Server Pages?)
Do Java Applets work in the browser?
[ Parent ]
[ Parent ]
[ Parent ]
Be sure that apt-get is accessing the contrib sources by ensuring that it is already in, or adding, "contrib" to the lines in the /etc/apt/sources.list file such that there are a couple of lines that read something like this: deb ftp://[mirror.server.best**]/debian/ stable main non-free contrib deb-src ftp://[mirror.server.best**}/debian/ stable main non-free contrib **: Replace [mirror.server.best**] with the name of a server that is 'net-CLOSE to you. Find some fine ones at http://www.debian.org/mirror/list and use the program 'netselect' ("apt-get install netselect" if you don't already have it) to determine the best (i.e. fastest) server from your suspected best list. ;-) e.g.: # netselect -vv debian.mirror.server.1 debian.mirror.server.2 debian.mirror.server.3 debian.mirror.server.4
[ Parent ]
[ Parent ]
[ Parent ]
I'm not sure that I agree.
If you build a new package, with a higher version number, then placing it within an Apt-get repository will allow simple upgrades.
Failing that a "dpkg --install newPackage.deb" will allow it to be upgraded. Sure you must generate the new Java Package, but otherwise you shouldn't have to remove the old one to upgrade.
I manage several machines all via a local repository so I can upgrade each machine just by uploading the new package to the trusted repository - there isn't anything magical about it, and it works nicely.
[ Parent ]
[ Parent ]
When there is a newere version from Sun the new package will have a higher version. So there's no need to mess with that.
For making a repository I tend to use reprepro which has been mentioned here before:
I hope that helps.
[ Parent ]
You also might want to mention that you may need to use the update-alternatives script so that /usr/bin/java actually points to the version of java you just installed.
Here's how I did it:
tom@homer:~$ sudo update-alternatives --config java
There are 4 alternatives which provide `java'.
Selection Alternative
-----------------------------------------------
1 /usr/bin/gij-wrapper-4.0
*+ 2 /usr/lib/jvm/java-gcj/bin/java
3 /usr/lib/j2sdk1.4-sun/bin/java
4 /usr/lib/j2sdk1.5-sun/bin/java
Press enter to keep the default[*], or type selection number: 4
Using `/usr/lib/j2sdk1.5-sun/bin/java' to provide `java'.
Then, to double-check your work, try the following command:
tom@homer:~$ 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)
If you installed the JDK, you might also want to check where the /usr/bin/javac symlink is pointing using this command:
tom@homer:~$ update-alternatives --display javac javac - status is auto. link currently points to /usr/lib/j2sdk1.5-sun/bin/javac /usr/lib/j2sdk1.4-sun/bin/javac - priority 314 slave javac.1.gz: /usr/lib/j2sdk1.4-sun/man/man1/javac.1.gz /usr/lib/j2sdk1.5-sun/bin/javac - priority 315 slave javac.1.gz: /usr/lib/j2sdk1.5-sun/man/man1/javac.1.gz Current `best' version is /usr/lib/j2sdk1.5-sun/bin/javac.
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
fakeroot is a program which pretends to be root to the scripts/programs it runs. So the script rightly thinks that you are root!
I'd take a first step of looking at existing bug reports for either fakeroot or java-package.
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
Looks like your problems aren't with the process, but with Knoppix:
cp: cannot create regular file `/ramdisk/home/root/sun-j2sdk1.5_1.5.0+update05_i386.deb': Permission denied
That error seems pretty clear to me. Being unfamiliar with Knoppix I'm not sure what to suggest, short of checking that directory is writable, or if ramdisk based contains enough free space to contain the binary .deb package.
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
deb http://ftp.no.debian.org/debian/ stable main contrib
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
The error should be obvious: "gcc: command not found ". That means exactly what it says, that the system tried to run the command gcc but failed because it wasn't available.
To fix this you should install the gcc command, via:
apt-get install gcc
You probably would also want to run:
apt-get install build-essential
[ Parent ]
[ Parent ]
[ Parent ]
I suggest you just apt-get install the java available to Ubuntu, rather than following this guide which is 2 years old.
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
Home is not neccessarily in /home/username, but it should be more easily and certainly in ~/ or $HOME/.
[ Parent ]