Archive for December, 2008

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)