def java(code, force=0):
	"""compile code snippet and return imported class"""
	codelines=code.split(";")
	for line in codelines:
		if line.find("class")!= -1:
			classname=line[line.find("class"):].split()[1]
			break
	try:
		oldcode=open(classname+".java").readlines()
	except:
		oldcode=""
	print >> open(classname+".java","w") ,code
	code=open(classname+".java").readlines()
	if(oldcode!=code or force!=0):
		retcode,retout,reterr=jythonc.javac.compile([classname+".java",])
		if retcode!=0:
			raise RuntimeError, reterr
	return sys.builtins["__import__"](classname)
compile code snippet and return imported class
recipes/Python/360875_inline_java_code_into_jython/recipe-360875.py