Avez-vous exploré cette commande d'exécution pour un Runtime java ? Créez un objet fichier avec le chemin vers lequel vous voulez "cd", puis saisissez-le comme troisième paramètre pour la méthode exec.
public Process exec(String command,
String[] envp,
File dir)
throws IOException
Exécute la commande de la chaîne spécifiée dans un processus distinct avec l'environnement et le répertoire de travail spécifiés.
Il s'agit d'une méthode pratique. Une invocation de la forme exec(command, envp, dir) se comporte exactement de la même manière que l'invocation exec(cmdarray, envp, dir), où cmdarray est un tableau de tous les tokens de command.
Plus précisément, la chaîne de commande est décomposée en jetons à l'aide d'un StringTokenizer créé par l'appel new StringTokenizer(command) sans autre modification des catégories de caractères. Les tokens produits par le tokenizer sont ensuite placés dans le nouveau tableau de chaînes cmdarray, dans le même ordre.
Parameters:
command - a specified system command.
envp - array of strings, each element of which has environment variable settings in the format name=value, or null if the subprocess should inherit the environment of the current process.
dir - the working directory of the subprocess, or null if the subprocess should inherit the working directory of the current process.
Returns:
A new Process object for managing the subprocess
Throws:
SecurityException - If a security manager exists and its checkExec method doesn't allow creation of the subprocess
IOException - If an I/O error occurs
NullPointerException - If command is null, or one of the elements of envp is null
IllegalArgumentException - If command is empty
0 votes
Un moyen de s'en sortir était de démarrer un nouveau shell et d'y envoyer toutes vos commandes - webmasterworld.com/linux/3613813.htm