Slashdot Mirror


Building the JDK on Debian GNU/Linux

Ivan Tarasov writes "Ever wanted to hack the JDK sources to get rid of some nasty bug which bothered you for so long, but was embarrassed by the complexity of the JDK build process? Now you have a good tutorial on how to do it on Debian GNU/Linux: last night I posted a blog entry on how to build the JDK 6 (sources of which are available at the Peabody site). This entry describes in detail which packages you need installed, how do you tweak the sources to make them buildable and how to proceed with the build. The build process for other Linux distributions must be very similar, so don't turn away if you don't use Debian. There is also a nice blog entry by Cay Horstmann "Honey, I built the JDK! (on Ubuntu)"."

27 comments

  1. That's all well and good, but ... by Jtoxification · · Score: 1

    When the code gets complex to a high degree, how can you ever be sure it's a bug in the JDK versus a bug in your code?

    --
    --I gots 99 problems but a new machine ain't one!
    AMD! Asus! Whoot! 6 years!
    1. Re:That's all well and good, but ... by Doctor+Memory · · Score: 3, Funny

      Well, duh. You've got the source, debug it!

      Kids these days...

      --
      Just junk food for thought...
    2. Re:That's all well and good, but ... by CastrTroy · · Score: 1

      And if it is a bug in the JDK, then submit a bug report to Sun, and get them to fix it, so you don't have to keep on patching all the future versions of the JDK you happen to want to use.

      --

      Anthropic principle: We see the universe the way it is because if it were different we would not be here to see it.
    3. Re:That's all well and good, but ... by Yuioup · · Score: 1

      Well, it's as easy as 1+1=3

    4. Re:That's all well and good, but ... by Anonymous Coward · · Score: 0

      This guy's member number is 4 digits. He probably doesn't even debug it in source form... just look at the binary that comes out of the interpretter... that's where it is.

    5. Re:That's all well and good, but ... by ximenes · · Score: 3, Funny

      I just hold the hard drive up to my ear to figure out JDK problems.

  2. Honestly? by zBoD · · Score: 4, Funny

    > "Ever wanted to hack the JDK sources to get rid of some nasty bug which bothered you for so long, but was embarrassed by the complexity of the JDK build process?"

    => no.

    --
    BoD
  3. Sun hotspot wins again by Anonymous Coward · · Score: 0

    If teh GCC was written in Java and Java was fully self hosted, build times would be reduced thanks to the miracle of JIT compilation. What else are you doing with that 20GB of RAM anyway?

  4. GCJ by legoburner · · Score: 2, Interesting

    Just want to mention GCJ, the java native compiler, part of the GNU tools. It still has quite a way to go, but for some standalone applications it is getting quite nifty. I am not sure what niche it fills yet but linking a native binary built from java source code feels strange.

    1. Re:GCJ by Golthar · · Score: 1

      What about JSP's?

      Because the classes are generated at runtime, GCJ forces you to run these at interpreted speed and can't compare with the current hotspot VM's
      Any big webapplication would be doomed unless you precompile the whole thing into a .so (yuck?)
      The biggest advantage of using GCJ would probably be in the fact that you don't need to lug a whole JVM (which is around 10 Mb) for a simple application.

    2. Re:GCJ by kwark · · Score: 2, Informative

      Once I thought that using gcj might be fine for running cli java programs but I found that gcj had the following problems:
      -the ahead of time compiling requires ALL sources to be compiled even though they are not needed at runtime. eg commons-cli.jar depends on commons-lang.jar in gcj as opposed to use in the Sun JVM.
      -it is very slow in some areas (about 3 times slower during disk IO and md5 checksumming)
      -I couldn't get it to create static binaries (dev. on Debian/unstable to run on Debian/stable), but this could be my fault.

      The only good thing was the slightly faster launch times (about 0.2ms on a process that runs 1.2ms total) compared to the Sun JVM. But since the program is only launched about 5 times per hour why bother.

      This was with gcj-4.0 some months ago.

    3. Re:GCJ by larry+bagina · · Score: 1

      Amen. MS = bad for having java with extensions.

      GNU = good for having java with extensions.

      If it's good for the goose, it's good for the gander.

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

    4. Re:GCJ by Anonymous Coward · · Score: 0

      Extensions are useful when you know whether you're relying on them. What Microsoft did wrong was to disguise their proprietary classes and methods as being part of the standard library (it sure didn't help that some displaced features that are part of the standard library, namely JNI and RMI). I haven't used GCJ, but I'd be pretty surprised if they didn't either name their packages honestly or offer a mode like "gcc -ansi -pedantic -Wall" that notifies you where you depart from the standard.

  5. Well... by Anonymous Coward · · Score: 0

    Ever wanted to hack the JDK sources to get rid of some nasty bug which bothered you for so long, but was embarrassed by the complexity of the JDK build process?

    No... I have a life.

    Thank you... Thank you... I'll be here all night...

  6. License? by SanityInAnarchy · · Score: 1

    I've heard Java is to be open sourced, but what is the JDK license at the moment? To what extent can I modify and redistribute?

    --
    Don't thank God, thank a doctor!
    1. Re:License? by ForumTroll · · Score: 2, Informative

      IIRC you can modify it as much as you like for your own personal use but you can't redistribute it.

      --
      "A Lisp programmer knows the value of everything, but the cost of nothing." - Alan Perlis
    2. Re:License? by ForumTroll · · Score: 1

      In all honesty, I'm not sure if distributing patches would be acceptable, I do have my doubts about that though. You'd have to really study the entire license to be sure of that, and unfortunately due to the way the license is written it would probably be best to check directly with Sun or a lawyer who handles software licenses regularly to be sure.

      Hopefully, Sun will choose an open source license which resolves most of these uncertainties.

      --
      "A Lisp programmer knows the value of everything, but the cost of nothing." - Alan Perlis
    3. Re:License? by SanityInAnarchy · · Score: 1

      Hopefully, yes. But how do you legally prevent distributing patches? I'm sure patches can be done in such a way that they don't expose any of the original code, although it does make them more likely to fail when files change.

      --
      Don't thank God, thank a doctor!
    4. Re:License? by LizardKing · · Score: 1

      Ah, ok. Can I distribute patches?

      Yes, that's exactly how you get the patchsets that enable JDK builds on FreeBSD and NetBSD.

  7. Re:Not the real problem by kwark · · Score: 2, Funny

    "I eventually solved this by using dpkg to build a one-on-one package from the JDK binary tree and told it to provide "java-virtual-machine, java2-runtime" and to make it conflict with: "kaffe, java1-runtime, java-compiler, fastjar, libjessie-java, java-common, gcj-4.0, ecj, ecj-bootstrap-gcj" after which I finally managed to get rid of the open source abominations once and for all."

    Why do it the easy way with make-jpkg and the alternatives system when you can do above :)

  8. Re:Not the real problem by Anonymous Coward · · Score: 0

    Because make-jpkg doesn't get rid of the open source variants, and after having wasted too much time on that software wondering why my study projects don't work I simply want them totally gone from my system. Another issue is keeping multiple JDK versions around.

    make-jpkg is a good program but can't do all of this. There is also the fact that this software has been build around the current Java release, and there is no telling how it might cope with future releases (granted: this is a minor issue).

    As you may know there are several Java versions around and now that Netbeans 5 has native support for maintaining and using several JDK's I also want to be able and actually keep several versions around. For example; at some customer places they're working with 1.5-6 and at the moment Sun released 1.5-8. Its pretty common and practical to use the latest JRE / JDK for home/private use but its not how its done in the real world. Now, I guess I could keep a strict eye open for features specific to >1.5-6 and try to be sure not to use them on my clients projects but why make it harder on myself just to conform to the "Debian way of doing things" ?

    I'd rather use the approach which works for me instead. Which is packaging up the JDK in such a way where I can keep multiple versions lying around, then I simply assign the 1.5-6 JDK to my customer projects and let Netbeans sort out my code to make sure that the software I'm writing actually works on the JVM they're meant for.

  9. Re:Not the real problem by kwark · · Score: 1

    I don't get your problem, if you don't want any of the OS java environments: uninstall them. Any java package that depends on any specific OS JVM is either not a java package or has a broken dependency (it should depend on java2-runtime)

    But to be honest: I don't use any java packages in any distro. Since client projects tend to be a mix and match of different versions of applications and JVMs I just install them all by hand in /usr/local and adjust $JAVA_HOME or symlinks when needed.

  10. Re:Not the real problem by BigFootApe · · Score: 3, Informative
    Are you thinking that Sun JDK will conflict with, say, SableVM? Milarky! You just use update-alternatives to point javac, java, javaw, etc. at Sun JDK as the primary provider of said facility.

    e.g.
    update-alternatives --config java
     
    There are 4 alternatives which provide `java'.
     
    Selection Alternative
      1 /usr/bin/gij-wrapper-4.0
    *2 /usr/lib/j2sdk1.5-sun/bin/java
    +3 /usr/lib/jvm/java-gcj/jre/bin/java
      4 /usr/bin/gij-wrapper-4.1
     
    Press enter to keep the default[*], or type selection number: 2
    Using `/usr/lib/j2sdk1.5-sun/bin/java' to provide `java'.
    Simple, no?

    Sorry, it would look nicer if slashdot accepted preformatted text :(
  11. Re:Not the real problem by MemoryDragon · · Score: 1

    which is still too much for the average end user who just wants to run azureus... I hope the gcj based compiles are replaced by the native sun jdk in the next version now the license issues are cleaned up, as good as gcj is, the native java is almost twice as fast....

  12. Re:Not the real problem by Anonymous Coward · · Score: 0

    Well, I'm sorry but perhaps as long as Sun is incapable of providing a good freely distributable java packages, that can be packaged easily in linux distro's on all arches (still haven't seen a good Sun jdk for linux-ppc), there is a need for a better and free java. I think java isn't used more on linux exactly because it choose not to play along with the ideals of the movement. That's fine, but do not complain about that. If Sun wants to make java prevalent on linux systems they should really free it. It's fine if they do not.

    Eventually gcj will become better. Or maybe not. For some apps it works quite nicely already. But for the moment, I happily stay with a more free language like C. Even although it has problems. It works best on my systems.

    Again let me make clear that I have nothing against java itself. It just doesn't work/integrate well on my system. So a java app can never really take off on linux. That's too bad. But as you say, live and let live, we just search for alternatives.

  13. Re:Not the real problem by kevlarman · · Score: 1

    the average end user who just wants to run azureus can find sun's java in synaptic just fine, though some way to ask if you want sun's java to be the default when you install it would be nice (not sure how to do this though, changing things without asking is always a bad idea, and asking for user input is not an option with dpkg)

    --
    A mouse is a device used to point to the xterm you want to type in
  14. Amusing troll by Anonymous Coward · · Score: 1

    http://blogs.sun.com/navi/entry/try_this_at_home_b uilding

    "Does java still take an hour and a half to compile 'hello troll!' on my 486?

    Posted by trolly troller on August 26, 2006 at 05:12 PM PDT "