I am developing an Android application where I need to execute the java binary from an extracted OpenJDK 22 package. The Java binary is located in my app’s external files directory (/storage/emulated/0/Android/data/com.my.newproject31/files/jdk-22.0.2/bin/java
) and in (/data/data/com.newproject31/files/jdk -22.0.2/bin/java
). However, when I try to execute the binary to check java version through java -version
using Runtime.getRuntime().exec()
, I encounter a “Permission Denied” error.
Extracted OpenJDK: I extracted the OpenJDK package to my app’s external files directory.
Tried to Execute: I attempted to run the
command /storage/emulated/0/Android/data/com.my.newproject31/files/jdk-22.0.2/bin/java -version and /data/data/com.my.newproject31/files/jdk-22.0.2/bin/java
using Runtime.getRuntime().exec()
.
Permission Denied: Every time I run the command, I get the following error: java.io.IOException: Cannot run program "/storage/emulated/0/Android/data/com.my.newproject31/files/jdk-22.0.2/bin/java": error=13,Permission denied
Checked Permissions: I have read/write permissions for this directory, but it seems Android does not allow executing binaries from external storage due to scoped storage restrictions introduced in Android 11.
Is there a way to execute binaries, like the java binary from OpenJDK, within an Android app on Android 11?
Android Version: 11
Target SDK: 30
6