问题
How can I start with dalvikvm an .jar-file with an input. Something like that:
dalvikvm -cp /path to jar/test.jar "hello"
The main method of the test.jar will be just print this hello to console. It something like that possible? What is the right way to give this input to the main method, for example as an input for String [] args of the main method.
回答1:
Have you followed these steps? It looks like you need to run something like this:
# /system/bin/dalvikvm -Xbootclasspath:/system/framework/core.jar -classpath /data/CmdLine.jar org.apache.HelloWorld /system/bin/dalvikvm -Xbootclasspath:/system/framework/core.jar -classpath /data/CmdLine.jar org.apache.HelloWorld
Hello World!
回答2:
I did something similar: /system/bin/dalvikvm -Xbootclasspath:/system/framework/core.jar -Xverify:none *-Dosgi.debug=file:/data/.option*s .........-Dosgi.parentClassloader=ext -classpath ..... -console -clean
Instead of passing parameters through String[],I do not know how to do in this case, you could use the -D"nameparameter"="value" format (see adb shell dalvikvm -help) that allows you to define also new parameters (I used only predefined ones) and send them to the vm; then in your main class you could get them using String prop=System.getProperty("nameparameter")
来源:https://stackoverflow.com/questions/8885269/dalvikvm-with-input