views:

83

answers:

3

I have a JAR file midlet JAR file, which returns an INT value according to some input data...

Problem is, i need to get that INT value by calling the jar file via some python code (and send the required input data to get the result data). How can i access the functions and variables of a midlet JAR file?

I try to decompile JAR into java code, but result was useless. Somehow, i need to get the code or get the related data that evaluated by JAR file?

Is it possible? If so, how can i do?

A: 

Jython has native access to Java code, but I'm not sure if it supports MIDP.

Ignacio Vazquez-Abrams
A: 

I don't know much about J2ME, but you might be able to use Python's pipe facility to invoke a method in the JAR, e.g. java -jar myjar.jar org.package.Main param1. See also the java command line options for your OS.

Addendum: The example in the pipe documentation shows how to read the result of a command. You may have to write your own main() method that uses introspection in order to invoke the target method with the correct parameters, as discussed in this JavaWorld article: Take an in-depth look at the Java Reflection API.

trashgod
Edit: Problem is, i do not write this code, and i do not have the java code, i just get the code by means of a decompiler. So code contains sinplified names for variables and functions like a,b,c... So, the function that i have to pass some params is not the main function, and i also need to get the result of a return statement into my python code... From this point of view, it looks nearly impossible ):
FallenAngel
I've made some additional suggestions above.
trashgod
A: 

A MIDlet can not run in a standard desktop JVM because it needs some extra libraries. But you can use an emulator like http://www.microemu.org/ to run the program. How to access a specific function inside the code, call it with specific parameters and read the result will be a real challenge. But MicroEmu is open source, so I'm sure it is possible. You will need some (probably advanced) java skills. Another option lighter than MicroEmu is http://kobjects.sourceforge.net/me4se/

Pablo Grisafi