posted on: 2009-01-09 20:03:35
the java WTK only seems to work with jad files and not jar files, but phones only need the jar file. So I think the information is found in the MANIFEST.MF so I wrote a script that converts the manifest to a .jad file. It has to add two lines.
>the java WTK only seems to work with jad files and not jar files, but phones only need the jar file. So I think the information is found in the MANIFEST.MF so I wrote a script that converts the manifest to a .jad file. It has to add two lines.
#!/usr/bin/env python import os,sys,subprocess def ExtractJad(fname): """This will extract read the manifest-nf and create a jad file that can be loaded by the loader""" #tests check = True if os.path.exists("META-INF") or os.path.exists("META-INF/MANIFEST.MF"): check = False print "There is already a META-INF directory" if not (os.path.exists(fname) and fname.endswith('.jar')): check = False print "invalid filename/file does not exist" if check: prog = subprocess.Popen(['jar','-xf',fname,"META-INF/MANIFEST.MF"]) rc = prog.wait() if rc==0: newname = fname.replace('jar','jad') outdata = "MIDlet-Jar-Size: 100\nMIDlet-Jar-URL: %s\n"%fname oldmanifest = open("META-INF/MANIFEST.MF",'r').read() outdata += oldmanifest newjad = open(newname,'w') newjad.write(outdata) newjad.close() os.unlink("META-INF/MANIFEST.MF") os.rmdir("META-INF") else: print "the .jar did not extract correctly" try: for item in sys.argv[1:]: ExtractJad(item) except IndexError: print "usage: mjad.py filename.jar"
or you could d/load the file from here mjad.py.
For the record this only makes a jad file for a working j2me jar file. If you want to make the jar file, then you should get the java WTK tool kit.
Comments
create comment?