[Howto] Sun Java on Fedora 7 [2. Update]

For legal reasons Sun’s Java is not included with Fedora 7 yet. However, with a bit of effort you can install it in a sane way.

The stress is on “a sane way” because the different Java versions could interfere with each other. Also, if you do it the wrong way, your java might be upgraded to the new, Fedora own version gcj.

However, before you start you should be sure that you really need Sun’s Java: read the Java FAQ from the Fedora project and also the information about the current state of OpenJDK on Fedora.
Also, first look at the Current Issues mentioned below before you start following this Howto!

The main part of this howto is taken from Jpackage’s help pages, which are much shorter and not distribution specific.

Download and Install

Here are the steps you have to do:
Prepare your system by installing necessary build tools (yes, you do have to compile stuff, unfortunately): yum -y install rpmdevtools. Also, make sure the package jpackage-utils is installed, which should be default.

Afterwards, download the latest java-1.x.0-sun-1.x.0.x-1jpp.nosrc.rpm package from the non-free branch at jpackage. In this case I took the 1.5.0 file.
It is a source rpm file, therefore it will install itself into /usr/src/redhat/... if installed as root, or into the local package build environment if installed as user.
Afterwards, check the given spec file java-1.x.0-sun.spec which is in .../SPECS or similar but in your home directory. Again, in my case it was a 1.5.0 file.
Now you have to download the appropriate java bin file from Sun – and this can be a bit tricky. In the worst case check the mentioned spec file for any link (search for the string http) – in my case I found the needed binary here.
Take the SDK and download the binary, not the self extracting RPM, to the .../SOURCES directory. Make also sure that the minor numbers of the binary are ok with the numbers given in the spec file: in my case the binary had the minor version 1.5.0-12, while the spec file defined the buildver 11. Correct this if needed.

Afterwards, recreate the java rpm: rpmbuild -ba java-1.x.0-sun.spec. You should find your new java binary in .../RPMS/i586. If they are not there, something went wrong, and you should hurry over to the next Fedora specialized forum.

However, if it did work, you can now install them. There might be some dependencies, solve this by using yum:
yum --nogpgcheck localinstall java*.rpm
You need the no-gpg option here because your local created rpms are not signed, of course.

Configure your system

After the install your basic system should already be configured:

$ java -version
java version "1.5.0_12"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04)
Java HotSpot(TM) Client VM (build 1.5.0_12-b04, mixed mode)

If this did not happen for any reason, change the default java system to Sun’s:

/usr/sbin/alternatives --config java

You also might want to install the Firefox/Mozilla plugin:

ln -s /usr/lib/jvm/java-1.5.0-sun- /usr/lib/mozilla/plugins/libjavaplugin_oji.so

Current Issues

This way has one current issue: the spec file calls the mkfontdir executable at the wrong place, resulting in an error during install of the java-fonts package. However, patching a spec file would go beyond this short point&click howto (although it is already a bit beyond that).

For a working Java Web Start look at this posting. You might also want to have a look at the much shorter version of the pure Java post here by Avi Alkalay posted in the comments. However, no guarantee that it works.

2. Update
The FedoraFAQ has recently renewed the part about Fedora and Java. The way mentioned there could also work as an alternative for many people.

65 thoughts on “[Howto] Sun Java on Fedora 7 [2. Update]”

  1. Hallo.

    I did everything on this site to install java.

    But when i type java –version only this option comes up:
    java version “1.5.0”
    gij (GNU libgcj) version 4.1.2 20070502 (Red Hat 4.1.2-12)

    pls help


  2. Not for me – it is most likely that you missed something in the install procedure. Please refer to a forum to solve this problem, a blog is not really a good place to discuss probable problems or to look into configuration files.

    But one thing you might want to test before you go to other forums:
    a) check if the Java rpms are really installed
    b) check if you can see two options at /usr/sbin/alternatives –config java

  3. rpm -qa|grep java
    This should unveil packages called java-1.5.0-sun …
    If they are not there I cannot help you here, please ask for help at a forum like fedoraforum.org

  4. Hello!

    Thank you for the nice and concise howto! Using it, I have successfully built and installed JDK onto Fedora 7 running on AMD64 architecture (taking the appropriate JDK bin file from Sun, of course).


  5. I’ve been dancing around the same thing on this since FC3 when I first picked up on Fedora. I just download and install the JDK from sun’s site, and then do an:

    ln -sf /opt/jdk1.6.0_01/bin/* /usr/bin/

    …and then it all works like a charm.

  6. If you follow that path you might be faced with problems when other java parts of the system are updated: keep in mind that you have two java binaries installed atm which might give you some headaches.

  7. I think you can make this procedure a bit shorter:

    1. You don’t have to open or install the nosrc.rpm. Just download it.
    2. You may find the Sun’s JVM binary home URL simply doing an ‘rpm -qpi java*nosrc.rpm’ and looking on the package information. Of course you’ll still need to browse, register and download.

    Then you put the downloaded binary in the SOURCES dir of your RPM build tree (probably $HOME/src/redhat/SOURCES to follow the standard), and fire this command wherever your nosrc.rpm file is:

    bash$ cd /directory/for/the/downloaded/nosrc.rpm/
    bash$ rpmbuild –-rebuild java*nosrc.rpm

    You will get an instalable JVM under $HOME/src/redhat/RPMS/

    I documented this procedure a few years ago, in brazilian portuguese, inside an article about Java on Linux with a broader scope.

  8. Nice one – I thought about something similar, but then decided to go the long way because in my experiences the paths and such stuff often change.
    However, thanks for the comment, next time I might try to use that way first!

  9. Christoph, the arch is usually a system variable: if you have a x86_64 system your package is most likely build for x86_64.
    To build packages for other architectures than your own system you have to ask at a Forum or other places, I never tried that.

  10. Hello,

    I’ve read a lot of HOWTO’s about sanely installing Java on a stock Fedora 7 system. However, none of them worked for me, in the sense that one acquires Java support for some application and breaks another (as an example: the main reason I was unable to install Fedora Directory Server is the hard way to install Java support).

    I also can’t understand why all HOWTO’s refer to Java 1.4.x or 1.5.x, when Java 6 is the current version.

    Could you please point me to some online reference where I can read about installing (and cleanly uninstalling) Java 6 on Fedora 7 using RPM ?

    I basically need:
    – support for Java in Firefox
    – Fedora Directory Server

    I also noticed that directly installing the Sun’s binaty rpm for Java 6 steals the .odt extension from OpenOffice, transforming it in “Java archive”. This is pretty annoing.

    Many thanks,

  11. Hi Răzvan,

    the main problem is that jpackage, *the* source for Java on Linux, does not provide a new srpm for Java 6 for the method described above yet.

    However, this might work:
    Download the JDK6u1 from the Java download website – take the self extracting rpm!
    Afterwards, download the *newest* java compat rpm from here. This should be java-1.6.0-sun-compat-

    Put them both in one directory, extract the rpm, and install them both at the same time with rpm -Uvh *.rpm command.

    This should work – everything which is missing now is configuring your system to access the right java installation:
    /usr/sbin/alternatives --config java
    There you can see all installed java versions – simply choose the number of the installation you want to use, and ready.

    Also, you might want to configure javaws in the same way. For that you might have to call the command
    alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/java-1.6.0-sun- 1
    Afterwards, again you have to configure your system to the right version:
    /usr/sbin/alternatives --config javaws

    It worked for me, btw.

    Good luck.
    If it doesn’t work it is a bit tricky to give appropriate help via a blog. You might want to join a good forum or contact me by mail/jabber, we might be able to work it out. But try the way above first, if your system is a normal Fedora 7 installation it should work.

    As a last note: I really hope that we don’t have to deal with that stuff anymore anytime soon.

  12. I used Avi Alkalay’s method (which is also the method described on fedorafaq.org). Everything is fine until I try to install the resulting rpms. I get the error ‘/usr/X11R6/bin/mkfontdir is needed by java-1.5.0-sun-fonts-’.

    You state this is a current issue, but would you happen to know a fix, because as it stands these rpms just won’t install. It seems mkfontdir has moved to /usr/bin on Fedora 7, but a simple symlink won’t work as rpm looks for a package providing /usr/X11R6/bin/mkfontdir. How do I get around this?

  13. breun, this error should not prevent the rpms from install! Check the rpm database of the rpm really havne’t been installed.

    Anyhow, a workaround would be to manually create the asked directories and place there a link to the real mkfontdir binary.

  14. After rpmbuild is done ‘rpmbuild –rebuild java-1.5.0-sun*src.rpm’, this plugin ‘libjavaplugin_oji.so’ is build for i386 but not for amd64.

    Further investigation reveals that (my assumption) jdk for amd64 does not support this.

    Am I right?

    Thanks in advance.

  15. Ramana: You are rebuilding according to a howto written by Avi Alkalay. I never proposed the rebuilding of the srpm!

    So please ask there, or try the build way mentioned in this howto to ensure you really build everything by hand. If that still builds for i386 instead of amd64 you have to ask in a forum – I do not have a amd64 machine and cannot help you there.

  16. The jdk 1.6 nosrc RPM spec file needs tweaking:in multiple places.

    again the mkfontdir gets called wrongly, and java odbc RPM initially failed to install, looking for libodbc.so and libodbcinst.so which were already in /usr/lib

  17. RE: Fedora 7 and java-1.6.0-sun-
    – the same problem is occurring on Fedora 7 with java-1.5.0-sun-
    – the compat files java-1.5.0-sun-compat- and java-1.6.0-sun-compat-

    I had to make some adjustments to that spec file in order to force a successful install on Fedora 7.
    I used my own local user rpmbuild – created with rpmdevtools
    I always test with yum localinstall to ensure the package dependencies are working properly in yum.
    I am not an RPM developer, so I know that my fixes are not very clean, this is what I was able to figure out through trial and error and by researching the dependencies on the Internet. I hope this helps you out, I am still not sure if everything is going to work properly, all I do know is that I did successfully install and I thought I should let you know what worked.

    This is partly because of strange dependency issues in Fedora 7
    – unixODBC and unixODBC-devel – libodbc.so.1.0.0 and libodbcinst.so.1.0.0
    – and because mkfontdir has been moved to /usr/bin

    # To correct issues with mkfontdir location in Fedora 7 – changed this line:
    # %define x11bindir %{_prefix}/X11R6/bin
    %define x11bindir %{_prefix}/bin

    this above change is to fix the issues with the font package and the new location of mkfontdir in Fedora 7:
    %package fonts
    Summary: TrueType fonts for %{origin} JVMs
    Group: Text Processing/Fonts
    Requires: %{name} = %{epoch}:%{version}-%{release}, %{_bindir}/ttmkfdir
    Requires: %{_sbindir}/chkfontpath, %{x11bindir}/mkfontdir, mktemp

    This next issue is regarding libodbc.so and libodbcinst.so from unixODBC and unixODBC-devel
    – the result of this change was to change the dependency from libodbc.so and libodbcinst.so to unixODBC
    – libodbc.so and libodbcinst.so are both present in /usr/lib
    – they are symlinks of the actual files libodbc.so.1.0.0 and libodbcinst.so.1.0.0
    # Avoid RPM 4.2+’s internal dep generator, it may produce bogus
    # Provides/Requires here.
    %define _use_internal_dependency_generator 0
    # Added this line – I had to use the specific build path of the jdk files
    %define our_find_requires %{_builddir}/jdk1.6.0_02/find_requires

    At the end of the %prep section I added the following:
    # Kludge to remove bogus odbc dependencies
    cat %{our_find_requires}
    echo unixODBC
    exec %{__find_requires} | /bin/egrep -v ‘^(libodbc(inst)?\.so)$’
    exit 0
    chmod +x %{our_find_requires}
    %define __find_requires %{our_find_requires}

    So far Java appears to be working, the browser plugin is working, and my java applications are able to launch and run. The Java Control Panel and the Jave Web Start in the System > Preferenced Menu are not launching. This could be a problem with where they are pointing, or with something else. Java Web Start applications are working too, so even though the control panel programs don’t launch from the Gnome Menu, the actual plugin/command is working when launched from the program folder.


  18. Hi Gerald,

    Thanks for sharing your experiences. There are still some issues though:

    – in exec %{__find_requires} | /bin/egrep -v ‘^(libodbc(inst)?\.so)$’ , there are some strange quotes. They should be replaced by regular single quotes. Probably something got screwed up while pasting.
    – I don’t have the find_requires file. I do have find-requires (with a dash instead of an underscore). It’s located in /usr/lib/rpm/redhat amongst others…


  19. Gerald: nice changes! I would like to ask you to submit them upstream directly, I’m sure the people there will look at them and hopefully adopt them.

  20. To clarify Gerald’s suggestions, you have to install the jpackage nosrc rpm (with rpm -i). This will put the spec file in ~/rpmbuild/SPECS. Then edit as Gerald described.

    Next, rebuild the nosrc rpm with “rpmbuild -bs -v SPECS/java-1.5.0-sun.spec”.

    Then proceed as in the original article.

  21. I did actually send them to the maintainer at jpackage.org. I think the problem is that the changes are what is needed to make it work on FC7 and are not necessarily backwards compatible. They may have to do a special section in the spec that detects if it is being built on FC7.

    Johny is right, and thanks for posting some of the commands Johnny, that was my bad. There is more to my suggestions than I wrote, I am sorry about that actually, I was really tired (spent hours trying to figure it out and looking up suggestions all over the net). The scripts I added to fix the problem with unixODBC actually come from another web site, I just can’t remember which url it was. it may have been fedoraforum.org actually and a suggestion for Java on FC4, and I tried it and it seemed to resolve the issue.

    After reading Johnny’s post I realized that I should give more information, or at least a step by step. I will try to find some time to put together a step by step and post it here.


  22. Just to clarify gerald’s post and dvlierop’s correction, the lessthan and greaterthan signs dont appear in posts, so dvlierop’s quote correction was right, but the build-requires correction was a misunderstanding. here are the two edits, as can be assumed from fep’s link.

    %define x11bindir %{_prefix}/bin

    instead of:

    %define x11bindir %{_prefix}/X11R6/bin

    %define our_find_requires %{_builddir}/%{toplevel_dir}/find_requires


    %define _use_internal_dependency_generator 0

    cat lessthanlessthanEOF greaterthan%{our_find_requires}
    echo unixODBC
    exec %{__find_requires} | /bin/egrep -v quot^(libodbc(inst)?\.so)$quot
    exit 0
    chmod +x %{our_find_requires}
    %define __find_requires %{our_find_requires}

    REPLACE the two “quot” with a single quote
    REPLACE the two lessthan with a less than symbol and the two the greaterthan with a greaterthan symbol

    at the end of:

    %prep section

    save the spec, follow liquidat’s original directions from here, which were just fine (starting from rpmbuild -ba)
    this worked fine on my system


    just download this:

  23. Your patch fixed the mkfontdir problem for me, but I’m trying to install the amd64 version of java and I’m still getting:

    Error: Missing Dependency: libodbc.so()(64bit) is needed by package java-1.6.0-sun-jdbc
    Error: Missing Dependency: libodbcinst.so()(64bit) is needed by package java-1.6.0-sun-jdbc

    Both libraries are in my /usr/lib64 directory.

    What would be the correct tweek to the spec file to make it work for the 64bit version of java as well?

  24. I found this, “%define __find_requires %{nil}” to be the incorrect way around the problem.

  25. the java odbc fails with the same Missing Dependency error for me as well. Even when using the new jpackage rpm from the updated spec file.

    but im on FC5 wanting jdk1.6.0_02.

  26. Have the same problem with libodbc.so and libodbcinst.so I simply dont have those… I have unixODBC installen but no named drivers with it. I have error “Missing dependency”. Is there any working solution?

  27. Initially I couldn’t rebuild the java-1.5.0-sun.spec on a x86_64 plateform (using jdk-1_5_0_12-linux-amd64.bin).

    But I went through it and this is how to:

    Same mkfontdir and ODBC dependencies issues:
    Worked around using the syntax from the link provided by fep.

    Regarding the installation of the rebuilded packages on a x86_64 platform, I had to install the unixODBC and unixODBC-devel packages from the i386 binaries, thus implying to install the following packages to resolve the dependencies:
    readline-5.2-4.fc7.i386.rpm, ncurses-5.6-6.20070303.fc7.i386.rpm

    FYI: These are the only non x86_64 packages installed on the system. There is no need to install a whole set of ix86 packages.

  28. jdk-1.5 install succefully with surfgate’s recommendations on packages, but i am still stuck with the “Missing dependency” error on libodbc with the 1.6 version…

  29. How difficult can it f***ing be to have the libjavaplubin*
    be part of the official JAVA distribution from Sun??

    How F***ing LAME is Sun????

    It is REALLY ANNOYING that there even has to be a thread
    on how to install JAVA on Fedora7 !!!!

    Damn, Sun SUCKS!!! Take a HINT Johnathan Schwartz!!

  30. Annoyed user: calmn down, it wont be an issue in the future. Java is opened up now, and although some bits are still missing, the path is clear: a full Java will be installed by default in the future in all distributions, and you will never have to worry about it again. 🙂

  31. It seems that the path to the Fonts encoding directory on FC7 does not match the spec file either. So you would have to modify it also, to this:

    %define x11encdir %{_prefix}/share/X11/fonts/encodings

  32. Error: Missing Dependency: /usr/X11R6/bin/mkfontdir is needed by package java-1.5.0-sun-fonts

    mkdir /usr/X11R6
    mkdir /usr/X11R6/lib
    ln -s /usr/bin /usr/X11R6/bin
    ln -s /usr/share/X11 /usr/X11R6/lib/X11

  33. Rls – You rock.. I tried

    mkdir /usr/X11R6
    mkdir /usr/X11R6/bin
    ln -s /usr/bin/mkfontdir /usr/X11R6/bin

    and it didn’t work. Your way works perfectly. Thanks!

  34. Thank you, it worked! 🙂

    first I tried the 1.6, but it failed on the dependencies, even with the file from john, but then i tried the 1.5 with the tips from Ris, and it seems to work now 😀

  35. Well, I use a differen rpm file to rebuild Java6 on F7. It was posted in the jpackage.org mailing list “https://www.zarb.org/pipermail/jpackage-discuss/2007-April/011323.html”
    (java-1.6.0-sun- by Lyle Dietz.
    It is also mentioned in the changelog of the RepoView for the *.nosrc.rpm of jpackage.org “http://mirrors.dotsrc.org/jpackage/1.7/generic/non-free/repodata/repoview/java-1.6.0-sun-0-”.

    The only thing I do is extract this file to the rpmbuild-directory and adapt the spec-file (changing the ‘buildver’ and ‘mkfontdir’).

    Then “rebuild -ba *.spec” and “yum –nogpgcheck localinstall *.rpm” and it installs without the libodbc*-issue.

    The Menu entries must be change manually, too. But the Java ControlPanel seems to work.

  36. using:

    I still get:
    Error: Missing Dependency: libodbcinst.so is needed by package java-1.6.0-sun-jdbc
    Error: Missing Dependency: libodbc.so is needed by package java-1.6.0-sun-jdbc

  37. The sheer length of this discussion suggests that things are still far from ideal for the end-user who would simply like to install (say) “javaws”.

    The opening (by liquidat) says: “For legal reasons Sun’s Java is not included with Fedora 7 yet.”. Note the “yet”, implying that things are expected to improve.

    Then on August 17th (three months ago), liquidat continues: “Java is opened up now, and although some bits are still missing, the path is clear: a full Java will be installed by default in the future in all distributions, and you will never have to worry about it again.”

    If the legal obstacles are now out of the way, then couldn’t someone with sufficient knowledge (as distilled above!) prepare the relevant RPMs for some sort of repository (even FC7 itself) so that the rest of us could simply “yum” them in (or similar)?

    I’m writing this with (more or less) an end-user perspective. But I would be happy to try out, and report back on, such a yum/RPM thing when it becomes available, even in beta.

  38. Due to historical reasons it is unlikely that there will be any of such free Java packages (called IcedTea) in Fedora 7.

    But Fedora 8 will ship with IcedTea and therefore will include a almost fully working JDK.

  39. Unfortunately, IcedTea as shipped with Fedora 8 is at best “almost working” (drop the fully). No sound, javascript, Java Web Start, etc mean that while the Test Applet functions and the shiipped Java apps such as Eclipse and Azureus work, many 3rd party programs, especially those of proprietary nature, fail badly.

    No matter what I’ve tried, I have not been successful in running Sun’s Java 5, 6 or even 7-ea (early access) builds on F8. I think it’s primarily AWT that is at fault — X11/libxcb can be worked around, but something else fails as well, and old workarounds such as legacy threading modes are no longer available in glibc 2.7.

    Bottom line: Java suffers from major regressions between F7 and F8.

  40. osma: I will try to have a look at it as soon as I have a running Fedora 8 here (that will be around release time).
    Until then you might want to fill a bug report against it.

  41. I am a beginner in Fedora7/Java. I used this webpage to successfully install Java version “1.6.0_02” (thanks to the tip from “Rls”). I am wondering how can I run/compile a java program that I have already written in Jcreator environment (in Windows). Here is what I got both before and after installing Java version “1.6.0_02”:

    $ java Gray_Interval.java
    Exception in thread “main” java.lang.NoClassDefFoundError: Gray_Interval/java

    Note: This java program runs without error in JCreator.

    Any help would be appreciated.

  42. Reza, since this post is quite old and is a blog post anyway I doubt that many people read this. The best is to have a look at a Fedora, or – even better – directly at a Java forum and ask there. A forum is a much better place to discuss problems. Plus, more people with knowledge are there usually 🙂

  43. Thanks liquidat. I thought this may be a trivial question and everybody knows about it.

    Anyways, this page was very useful to me.
    Thanaks again,

  44. Thanks very much for this. Worked like a charm. I only needed to edit the spec for the x11bindir line. After that, your suggestion to install the RPMs with yum –nogpgcheck localinstall java*.rpm worked flawlessly.

    Huzzah! jEdit is installed!

  45. Error: Missing Dependency: libodbc.so is needed by package java-1.6.0-sun-jdbc

    Error: Missing Dependency: libodbcinst.so is needed by package java-1.6.0-sun-jdbc

    if you’ve found this through google, then you’re life is going to get harder.

    you suck sun.

  46. Here is the solutions to solve the missing dependencies problem of
    libodbcinst.so, and mkfondir
    1. To solve libodbcinst.so in fedora 8 check weather you have installed the following packages.
    [root@localhost ~]# rpm -qa | grep unixODBC
    [root@localhost ~]#
    If you dont have the above packages, install them using yum and then run the java rpms.

    This above packages will install the dependencies in the necessary folders.

    2. To solve the mkfontdir depedencies problem, follow the steps given below…

    Error: Missing Dependency: /usr/X11R6/bin/mkfontdir is needed by package java-1.5.0-sun-fonts

    Step 1: #Prepare directory
    [root@localhost]# mkdir /usr/X11R6
    [root@localhost]#mkdir /usr/X11R6/lib

    Step 2:# Give Symblink
    [root@localhost]# ln -s /usr/bin /usr/X11R6/bin
    [root@localhost]#ln -s /usr/share/X11 /usr/X11R6/lib/X11

    Install the created RPMs
    $ sudo yum –nogpgcheck localinstall usr/src/redhat/RPMS/i586/java-1.6.0-sun-*

    This will definitely work.

  47. To get past the dependency problem I just did:

    rpm -Uvh –nodeps java*.rpm

    Worked like a charm. Now, Java apps work

  48. Hey, I am learning java using jGrasp on my Fedora8 laptop. I wanted to know if there and better compilers (better yet) GUI text editors to use. I started with vi then used vim which wasn’t bad at all just a little time consuming getting use to. The default text editor GEdit is awesome! I just have to keep using a terminal window to see my output.

    Any suggestions?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: