I am writing a java code that will append a path string to the %PATH% variable using java
In command prompt the command is
setx PATH "%PATH%;C:\my Path\"
In java here is my code:
import java.io.File;
import java.io.IOException;
public class AddToPATHVariable {
public static void main(String[] args) throws InterruptedException, IOException {
String folderPath = "C:\\my Path\\";
System.out.println(folderPath);
Runtime rt = Runtime.getRuntime() ;
Process p = rt.exec("setx PATH \"%PATH%;" + folderPath + "\"");
p.waitFor();
p.destroy();
}
}
The issue is that my command line prompt is append the new string perfectly. But java code is make the value to path variable to be %PATH%;C:\my Path\
誰かがこの点で私を案内してください。