I wrote a simple tool for producing jad files from jar files.
Just for fun.
/**
a simple tool for creating a jad file for a given MIDlet jar file. and launch WTK emulator to run it.
author: yi xiaoqiang
time: 2007-05-30
*/
import java.io.*;
import java.util.*;
import java.util.jar.*;
public class SimpleRunJarMIDlet
{
public static void main(String[]args) throws Exception
{
if(args.length == 0)
{
System.out.println("Usage:");
System.out.println(" java RunJarMIDlet XXX.jar");
}else
{
if(args[0].endsWith(".jar"))
{
String jarFile = args[0];
String jadFile = args[0]+".jad";
if(!new File(jadFile).exists())
makeJad(jarFile, jadFile);
Runtime.getRuntime().exec("C:\\WTK25\\bin\\emulatorw.exe -gui -Xdescriptor:"+jadFile);
}
}
}
static void makeJad(String jarFile, String jadFile) throws Exception
{
File file_jarFile = new File(jarFile);
long size = file_jarFile.length();
JarFile jarFile_jarFile = new JarFile(file_jarFile);
Manifest manifest = jarFile_jarFile.getManifest();
FileOutputStream out = new FileOutputStream(jadFile);
manifest.write(out);
String s = "MIDlet-Jar-URL: " + jarFile + "\n"
+ "MIDlet-Jar-Size: " + size + "\n";
out.write(s.getBytes("UTF-8"));
out.flush();
out.close();
System.out.println("Made: " + jadFile);
}
}