0

I am in the process of creating a program that will automate the packaging, signing and installing of an apk file.

I have 3 terminal commands listed below that I am unsure how to place into my Java program. This section of the program must be able to open a terminal, call these commands, and at one point allow the user to enter the password all from a Java IDE.

  aapt package -u -f -F "/home/jay/testing_FILES.apk" "/home/jay/testing_FILES"

  jarsigner -verbose -digestalg SHA1 -sigalg MD5withRSA -keystore my-release-key.keystore "/home/jay/testing_FILES.apk"

 zipalign -f -v 4 "/home/jay/testing_FILES.apk" "/home/jay/filesystem.apk"

Does anyone know how to make these run through a JAVA IDE? Thanks.

JJJ1106
  • 57
  • 2
  • 8

1 Answers1

1

Assuming that you can get the password through command line and somehow patch this as part of your command execution process, you can then call use Runtime.exec() to call these functions from your java program. You can consult the javadoc to get more information on this option

The other option is to use Plexus Utils. Have a look at this stackoverflow link

Community
  • 1
  • 1
Sujay
  • 6,753
  • 2
  • 30
  • 49
  • can you explain how to patch the password through because that is what is currently stopping me from using the runtime.exec()? – JJJ1106 Jul 16 '12 at 15:06
  • which one of the three needs a password? i think it would have an attribute to send the password as part of the command line argument. and assuming that it does, then you can take the password from the user and then use it as an attribute when you call your command using 'Runtime.exec()' – Sujay Jul 16 '12 at 15:09
  • only the second of the three requires the input of two separate password after calling this piece of code – JJJ1106 Jul 16 '12 at 15:15
  • you mean it needs a password to access the keystore? if that's the case then i guess the argument you need is "-storepass password". you can add it to your current set of arguments and take the password from the user before you call this command. Here's a link that might be helpful: http://docs.oracle.com/javase/1.3/docs/tooldocs/win32/jarsigner.html#Options – Sujay Jul 16 '12 at 15:20
  • thanks your right i never saw that before. thanks for the help! – JJJ1106 Jul 16 '12 at 15:24