Created
October 5, 2011 13:12
-
-
Save maluta/1264386 to your computer and use it in GitHub Desktop.
Command line Java on DalvikVM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
DIR="tmp_"$$ | |
JAR=`echo $1 | tr '.' ' ' | awk '{ print $1 }'` | |
rm -rf $JAR.jar | |
mkdir $DIR | |
cp $1 $DIR | |
cd $DIR | |
echo "** Compiling java file..." | |
javac -d . -g $1 | |
echo "** Creating temporary jar..." | |
jar -cvf Temp.jar * | |
echo "** Creating DEX file..." | |
dx --dex --output=./classes.dex Temp.jar | |
echo "** Creating Android compatible file..." | |
aapt add ../$JAR.jar classes.dex | |
cd .. | |
rm -rf $DIR | |
echo "** Finished!" | |
echo "" | |
echo "Now copy to your device, ex:" | |
echo "" | |
echo " adb push "$JAR".jar /data/local" | |
echo "" | |
echo "adb shell" | |
PACKAGE_NAME=`grep "package" $1 |awk '{print $2}' | tr ';' '.'` | |
CLASS_NAME=`grep -i "public class" $1 | awk '{ print $3 }'` | |
echo "/system/bin/dalvikvm -Xbootclasspath:/system/framework/core.jar -classpath /data/local/"$JAR".jar "$PACKAGE_NAME$CLASS_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// Example code
package br.com.coding;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}