Posts Tagged java

Java Web Start in 64-bit Linux

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)

Tags: , , ,

Memories of childhood

Today, I got a scanner and my brother wanted to scan some of our childhood photographs. So, we put four photos in each of corner of the scanner and scanned them.

After all, we had huge images, which should be split into four separate images. That was a pretty straightforward boring process. So, finally, I thought of writing a small piece code to split the images. and that�s written in JAVA :O. Code is not written for posting, so looks like poorly written code, but anyway it does the job.

import java.awt.image.*;
import javax.imageio.*;
import java.io.*;

public class ImageSpliter {
	public static void main(String args[]) {
		try {
			File file = new File(args[0]);
			int x = Integer.parseInt(args[1]);
			BufferedImage input = ImageIO.read(file);
			BufferedImage output = input.getSubimage(0,
							0,700,1000);
			File fo = new File("C:/photos/"+x+".jpg");
			ImageIO.write(output,"JPG",fo);

			output = input.getSubimage(0,
					1400,700,input.getHeight()-1400);
			fo = new File("C:/photos/"+(x+1)+".jpg");
			ImageIO.write(output,"JPG",fo);

			output = input.getSubimage(1100,
					0,input.getWidth()-1100,1000);
			fo = new File("C:/photos/"+(x+2)+".jpg");
			ImageIO.write(output,"JPG",fo);

			output = input.getSubimage(1100,
				1400,input.getWidth()-1100,input.getHeight()-1400);
			fo = new File("C:/photos/"+(x+3)+".jpg");
			ImageIO.write(output,"JPG",fo);
		} catch(Exception e) {
			System.out.println(e.toString());
		}
	}
}

Tags: ,

Netbeans 5.5 with Beryl

A solution emerged while doing little bit of browsing. Just have to export a variable :

export AWT_TOOLKIT=MToolkit

Tags: , , , ,

Get Adobe Flash playerPlugin by wpburn.com wordpress themes