How do I open vi editor from my Java application in the same terminal?… here is a solution to the problem.
How do I open vi editor from my Java application in the same terminal?
How do I open the vi
editor from my java app?
I’ve tried this
Process p = new ProcessBuilder("xterm","-e","vi /backup/xyz/test/abc.txt").start();
int exitVal = p.waitFor();
System.out.println("Exited with error code "+exitVal);
But this opens vi
in a new terminal. I want the vi editor to open in the same terminal where my app runs
Solution
It should be simple: skip xterm and start vi: directly
Process p = new ProcessBuilder("vi", "/backup/xyz/test/abc.txt").start();
If you want more command-line arguments for vi, add them as separate strings, not in the “” of the first argument.
Starting a terminal
program like vi naturally requires launching a java application from a visible terminal, so vi has a terminal to use, but I think so.