Java Web Start in 64-bit Linux

Wednesday, December 24th, 2008

If you are using 64-bit linux, you might have found out that jvm 64-bit version doesn’t have a java web start. (Update: Java Web Start is added to 64-bit package since the version 6u12) I don’t know any particular reasons for this, however jnlp files seem to be very simple. The jnlp file contains an url to a jar file, which we can download and run separately. I only tried this with topcoder arena – it works without any problems. Here is a python script for handling simple java web start files.

#!/usr/bin/env python

import xml.dom.minidom
from xml.dom.minidom import Node
import os,sys

if len(sys.argv) != 2 :
	print "Usage " + sys.argv[0] + " [jnlp file]"
	sys.exit()

doc = xml.dom.minidom.parse(sys.argv[1])

jnlp = doc.getElementsByTagName("jnlp")[0]
codebase = jnlp.getAttribute("codebase")

resources = jnlp.getElementsByTagName("resources")[0]
jar = resources.getElementsByTagName("jar")[0].getAttribute("href")

application = jnlp.getElementsByTagName("application-desc")[0]
main = application.getAttribute("main-class")
arguments = application.getElementsByTagName("argument")

cmd = ""

for a in arguments :
	cmd += " " + a.firstChild.data

filename = jar.split("/")[-1]

if not jar.startswith("http:") :
	jar = codebase + jar

os.system("wget -N "+jar)

os.system("java -jar " + filename + cmd)

Improve jhbuild downloading

Friday, April 11th, 2008

Yesterday, I tried to install Gnome Online Desktop. Since, this is fairly new, it has to be build from the source. Gnome Online Desktop is a complete branch of gnome desktop, which will of course have many dependencies. It’ll take years to download each and compile manually. That’s why they have jhbuild (it works like gentoo emerge).

This is April, which is supposed to be the best month of Sri Lanka with festivals/celebration. But there is a price to pay, thundering (Last year, lighting took my laptop :( ). My connection goes down for each 10 minutes.

So, while jhbuild downloading a module, the connection goes down, and when I restart jhbuild, download doesn’t continue from where I left off. It downloads the whole file again. So, here is a very simple one line hack to prevent that from happening to you.

In jhbuild/versioncontrol/tarball.py, line 171, add a command line option “-c” to wget command. If you are not happy with “wget”, you can change it to whatever you want(prozilla,aget,d4x).

I’m still building online desktop (101 packages :-/ ), can’t wait to see what it can do.

The Python Challenge

Sunday, September 16th, 2007

You might have already read my blog post about deathball riddle. Few days ago, I started doing another internet riddle, but not like deathball, this is a programming riddle. It’s python challenge.

You might not familiar with python, but this is definitely a really good way to learn the language. When, I started doing this, I only knew few syntax in python.. But after finishing several levels, I learned about some really good ways of using python – or I can say the art of python.

If you don’t know about python, It’s not a dead language or not a useless language. It’s quite powerful scripting language, which also have GTK bindings. Many of the novel linux apps are written in python. Gentoo emerge is a very good example.

Enhance Apt-Get downloading using an external download accelerator(axel/prozilla/aget)

Wednesday, February 14th, 2007

The Apt-Get in debian systems use their own downloading system to download packages from the internet. It supports file resuming and pipelining. However, it doesn’t support downloading using multiple threads, and it won’t allow you to external applications to download.

However, the http downloader is a separate application(/usr/lib/apt/methods/http) from apt-get, and the apt-get spawns the executable to download the files. Those two programs communicate via stdin and stdout. I have written a new downloading application which can communicate with the apt-get. So, I just copied the executable to /usr/lib/apt/methods/http. The new application spawns another program(In my case a shell script) with two arguments; the url and the local file.

So, after all my shell script calls a python script. My program doesn’t call the python script directly because when the python scripts gives some output to stdout/stderr the apt-get program crashes. So, my shell script redirects the all output to /dev/null. Then, the python script will get the url, do a HEAD request, get the file size. If the file size is less than 100K, it’ll execute wget, if not it’ll execute axel. So, the files will get downloaded and apt-get will install the software.

The apt-get update command fetches many small files from the same server. Since the original downloader uses pipelining, it’s much faster. I have to modify my code to do something about pipelining.

Files :

scripts.tar.gz

apt.tar.gz

Learning python

Thursday, December 28th, 2006

Last few days, I was sleeping at home enjoying the lazy days of Christmas vacation. Except sleeping, went on a trip to nuwaraeliya, and more interestingly after Anjana pointed out some key features of python, I decided to give it a try, so started learning it. After spending few hours, I managed to learn the syntax which was well managed so that easy to learn. However, the syntax itself doesn’t make python special; so I went little deeper down to the python lib. That’s what makes a real difference. Python comes with a large collection of libraries, and those are damn powerful and easier to use.

Learning is not only reading and going through the example source codes. It’s actually writing something, writing a real world application. So, I started to write a web log analyzer. First I separated the log file by the date, and calculated the statistics for each day and saved them in different files. After that I wrote a small php script when the two days are given, it collects statistics and generates a xml file. After that it’s all about the interface; My ajax interface process the xml file and gives a nice output of what I have calculated, of course with some graphs(plotkit did the graph magic with javascript). However it needs some cleanups (I originally hard coded the log urls/search engines/etc), and the config file support should be added to it. Once I’m done with those, I’ll upload the source code soon… Yes, it’s distributed under GPL.