1. Wrong way to use it
Runtime.getRuntime().exec("xxx");
2. Correct usage
//You need to specify parameter one: command location; parameter two: -c means execute the first parameter first; parameter three: your command.
Runtime.getRuntime().exec(new String[]{"/bin/sh","-c","xxx"});
Such as:
try {
Runtime.getRuntime().exec(new String[]{"/system/bin/sh","-c","reboot"});
}catch (Exception e) {
e.printStackTrace();
}
Read More:
- @requestbody: How to Use or Not Use
- JS: How to Solve split, join, toString Use error
- How to Use DOM to operate CSS
- How to use HPQC on Chrome browser
- Javascript: How to Use Date.Now() to implement front-end frequency limit
- Vue2.0: How to Use vue3 api to encapsulate Axios
- [Solved] Error in load assembly ‘System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1’
- Vue3.0 Use el-dialog visible Error: ‘.sync‘ modifier on ‘v-bind‘ directive is deprecated. Use ‘v-model:pro
- [Solved] fatal error: cuda_runtime.h: No such file or directory
- [Solved] Element form method resetfields() error: vue.runtime.esm.js?2b0e:1888 TypeError: Cannot read properties of undefined (reading ‘indexOf’)
- [Solved] Error while trying to use the following icon from the Manifest
- runtime-core.esm-bundler.js5c406620 [Vue warn] Unhandled error during execution of native event h
- Vue: How to Solve error avoided redundant navigation to current location: “/xxx”
- [Solved] gyp ERR! stack Error: Could not find any Python installation to use
- [error] IDE service port disabled. To use CLI Call, please enter y to confirm enabling CLI capabilit
- How to Solve Vue route jump repeated clicks Error
- After Vite starts, it will prompt “network: use ` — host ` to expose”, and the service cannot be accessed through network IP
- How to Solve Uncaught (in promise) Error (Two Solutions)
- [Solved] Msbuild: error msb3428: the group cannot use the visual c + + function “vcbuild. Exe”.
- [Chrome]: DevTools failed to load source map… (How to Solve)