Tag Archives: Development

Migrating to JRockit

I’ve been bothered with the now famous PermGen Space error while developing a web application on a local jetty instance quite often, and I was hoping that the problem wouldn’t prove to be that serious once deployed on a tomcat server, but quite the opposite is the case.

The problem happens when the JVM runs out of permanent generation heap space, which most of the time is due to classloaders not being correctly garbage collected. Permanent generation heap space is an optimization that the Sun JVM contains to speed up object creation, but the default size is too small if classes are loaded and unloaded often during runtime, which is exactly the mechanism most application servers load applications.

So the first, quick and dirty, solution would be to enlarge the permanent generation heap space: -XX:MaxPermSize=256m Sadly, this still doesn’t get rid of the problem. Another solution is to use a completely different JVM altogether: JRockit.

JRockit, a proprietary Java Virtual Machine (JVM) from BEA Systems, became part of Oracle Fusion Middleware in 2008.

Many JRE class files distributed with BEA JRockit exactly replicate those distributed by Sun. JRockit overrides class files which relate closely to the JVM, therefore retaining API compatibility while enhancing the performance of the JVM.

[from Wikipedia]

I wasn’t thrilled having to change JVM because it isn’t available in the openSuse repositories at all, and I wasn’t quite sure how hard it would be to make the switch. As I found out, it’s incredibly easy.

Getting the package

Getting your hands on the JRockit installation package isn’t all that easy, because BEA became part of Oracle and everything is still in transition. The download location is http://edelivery.oracle.com/, where you’ll be greated by a wizard to select the products to download.

JRockit can be found under BEA Products and then BEA WebLogic Media Pack, scrolling down you’ll find the zip package you need depending on your operating system.

Installation

Installation is straight forward, just unzip the archive and then execute the contained installer:

$ unzip B46961-01.zip
Archive:  B46961-01.zip
  inflating: jrockit-R27.5.0-jdk1.6.0_03-linux-x64.bin
$chmod +x jrockit-R27.5.0-jdk1.6.0_03-linux-x64.bin
$sudo ./jrockit-R27.5.0-jdk1.6.0_03-linux-x64.bin

Now all you have to do is follow the instructions of the installer. When asked for a location to install JRockit into, I used /opt/jrockit but every location will do just fine.

The next step is optional, but if you use update-alternatives I strongly suggest you to do it. We’ll add jrockit java and the the jrockit compiler (javac) as alternatives:

update-alternatives --install /usr/bin/java java /opt/jrockit/bin/java 300
update-alternatives --install /usr/bin/javac javac /opt/jrockit/bin/javac 300
So when doing an update-alternives we see the jrocki VM:
$ update-alternatives --config java

There are 2 programs which provide `java'.

  Selection    Command
-----------------------------------------------
 +    1        /usr/lib64/jvm/jre-1.6.0.u7-sun/bin/java
*     2        /opt/jrockit/bin/java

Enter to keep the default[*], or type selection number:
so now we can easily switch between the Sun VM and the JRockit VM. That’s it. Now just check to see if we really have the JRockit VM and we’re ready to code:
$ java -version
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
BEA JRockit(R) (build R27.5.0-110_o-99226-1.6.0_03-20080528-1505-linux-ia32, compiled mode)

  • Share/Bookmark

Adobe joins forces with Mozilla

Adobe has just announced a huge donation to the Mozilla foundation: a high performance ECMAScript Edition 4 Virtual Machine. Don’t know what ECMAScript is? It’s the standard behind JavaScript. Off course this is great news for all Ajax developers because it allows us to rely on the most powerfull Virtual Machine ever for our applications.
Advertisement BadgeWhen you convert PDF to Word you may find that any free PDF conversion sites online don’t give you the power that true PDF to Word software can give you; if you end up converting PDF to Word often then dedicated software might be a good solution.
Mozilla will host a new open source project, called Tamarin, to accelerate the development of this standards-based approach for creating rich and engaging Web applications. The Tamarin project will implement the final version of the ECMAScript Edition 4 standard language, which Mozilla will use within the next generation of SpiderMonkey, the core JavaScript engine embedded in Firefox®, Mozilla’s free Web browser. As of today, developers working on SpiderMonkey will have access to the Tamarin code in the Mozilla CVS repository via the project page located at www.mozilla.org/projects/tamarin/ . Contributions to the code will be managed by a governing body of developers from both Adobe and Mozilla. “Adobe’s work on the new virtual machine is the largest contribution to the Mozilla Foundation since its inception,” said Brendan Eich, chief technology officer, Mozilla Corporation, and creator of JavaScript. “Now web developers have a high-performance, open source virtual machine for building and deploying interactive applications across both Adobe Flash Player and the Firefox web browser. We’re excited about joining the Adobe and Mozilla communities to advance ECMAScript.” “This is a major milestone in bringing together the broader HTML and Flash development communities around a common language, and empowering the creation of even more innovative applications in the Web 2.0 world,” said Kevin Lynch, senior vice president and chief software architect at Adobe. “By working with the open source community we are accelerating the adoption of a standard language for creating and delivering richer, more interactive experiences that work consistently across PCs and mobile devices.”
Hopefully this will have an influence on the other browsers too and push them towards powerfull and standard compliant JavaScript implementation. I just can’t wait to see it in action :)
  • Share/Bookmark

Animation.js, keep it short, keep it simple!

Programmers love inheritance, they name their children like inherited classes, they implement interfaces and do other nasty things involving parent relations :P Not all of them: Bernie Sumption hates inheritance.
I was putting together my new home page the other day, and decided that the chicken could use some lipstick in the form of one of those new-fangled animated accordion widgets. I checked several different libraries and found them all to be lacking. In particular, they don’t seem to realise that inheritance is evil, and must be destroyed. By providing base classes for an effect and requiring users to subclass it to make new effects, they create a proliferation of classes and make it too hard to create new effects that the library designer hasn’t thought of (scriptaculous gets round this by thinking of every effect you might want, which is why it is so large).
Being a developer that loves a good challenge he simply made his own animation library: Animation.js. The code you get is very minimalistic and … beautiful. Programmers love not having to write too much, they hate verbosity, so keep the code they have to write short and they’ll love you :D
 
ex2 = new Animator({
     duration: 1200,
     interval: 400,
     onComplete: function() {$('ex2Target').innerHTML += "Bing! ";}
 })
 ex2.addSubject(updateButton);
 function updateButton(value) {
     $('ex2Target').innerHTML += " Badda ";
 }
 
ex13 = Animator.apply($('ex13Button'), "background-color: #3F9"); // ta da!
  • Share/Bookmark

Projax

The guys over at NGCoders have just released version 0.2 of Projax. It is basically a set of PHP Wrappers around Prototype and Script.aculo.us, ported directly from the Ruby on Rails helpers. It may speed up development significantly.
Check out the Demos:
I especially like the inplace editor which in my opinion is one of the most usefull features when developing Web 2.0 applications.
  • Share/Bookmark

CSS hacks

I know CSS hacks are just plain ugly and should be avoided at all costs, but sometimes its the best way to fix a problem with a certain browser. But will your hack affect other browsers too? If you ever wondered what other browsers will do with your hack there is a really nice reference: Will the browser apply the rule(s)?
  • Share/Bookmark