Friday Jul 18, 2008

Did you know, that there is a really simple way to set your Java environment in Ubuntu, when you have multiple Java packages installed?

Everything you need is to run update-java-alternatives command with correct parameters.

Just look at your installed Java packages (use ls -l /usr/lib/jvm/ command):

petr@pchytil-ws:~/nbsrc_main/main/mercurial$ ls -a1 /usr/lib/jvm/ 
.
..
java-1.5.0-gcj-4.2-1.5.0.0
java-1.5.0-sun
java-1.5.0-sun-1.5.0.15
.java-1.5.0-sun.jinfo
java-6-sun
java-6-sun-1.6.0.06
.java-6-sun.jinfo
java-gcj
.java-gcj.jinfo

You can see three .jinfo files here. Just take name of this files without extension and you have right parameters for update-java-alternatives command.

On my machine, I have three Java packages installed:

java-1.5.0-sun
java-6-sun
java-gcj

So choose the package you want and run

sudo update-java-alternatives -s <java_name> 

for example i want to use JDK 6.0:

sudo update-java-alternatives -s java-6-sun

This command creates links for all important Java binaries. java -version command should now give you the Java version, which you always dreamed of ;-).

petr@pchytil-ws:~$ java -version
java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) Server VM (build 10.0-b22, mixed mode)

Wednesday Jul 09, 2008

 I have to share my today's work experience with you. I was going to do some testing of one new NetBeans IDE 6.5 features. It is improved support for new Java Web Start features which will come with incoming Java SE 6 update 10. I saw many full-featured applications, which were able to start directly from a web page. And NetBeans IDE has features to help you easily create such application. Just open your project's properties and you're in.

But I'm not going to write about Java Web Start technology. It is nothing new. Today, I was looking for some applet, which uses JNLP to test the next-generation Java Plug-In installation in my Firefox 3. And you now what? I've ended playing Quake 2 inside my browser's window!

Playing with next-generation Java Plug-In on Firefox & Ubuntu

But let's start at the very beginning of the story. I was standing in front of task to install the next-generation Java Plug-In, which comes with Java SE 6 Update 10. I am running Ubuntu 8.04.1 desktop. The installation process of Java Plug-in has changed a little since previous version of the Java Plug-in. So I followed the installation steps and removed any preexisting symlinks to the libjavaplugin_oji.so. But despite of that applets were not working. So I wrote about:plugins into Firefox address bar and found out, that Firefox is still using Java Plug-in from JDK 6 update 6 and not the new libnpjp2.so. I was not able to locate any symlink to libjavaplugin_oji.so on my system, so I had no clue how to get rid of non-existing symlink. Then I realized, that I had installed sun-java6-plugin. Solution was simple:  sudo apt-get remove sun-java6-plugin. That was it. Applets began to work properly.

Next-generation applets

You may know about Jake 2 project. I had no idea, that something like this exists. So you can imagine my surprise, when one of the demo applets on the next-generation Java Plug-In page showed up to be the mentioned Jake 2 project running in web browser as an applet. And the performance was stunning! Just have a look at their benchmarks. Such an applet was far beyond my imagination. My development experience with applets ended on small school project, which simulated behavior of rabbit and wolves populations. Looks like lots of unused potential in this technology, does it?

How to easily create such applet?

Are you bored with demos created by others? So grab NetBeans IDE 6.5 M1 - our latest stabilized development  build at NetBeans download page and try to create your own applet with powerful JNLP technology. I'll write short how-to next time. Just to keep posts reasonable long.

This blog copyright 2009 by Petr Chytil