I need to open a txt file from a location on Ubuntu (e.x. /usr/local/share/SomeFolder/Readme.txt) through my java code.
I've used Runtime.getRuntime.exec(String) and Runtime.getRuntime().exec(args) with gedit but it opens a new tab alongside the Readme.txt file.
The code is as below
String x="gedit /usr/local/share/SomeFolder/Readme.txt";
Runtime.getRuntime.exec(x);
<OR>
String[] args={"gedit","/usr/local/share/SomeFolder/Readme.txt"};
Runtime.getRuntime().exec(args)
I've also tried using ProcessBuilder but it behaves the same way. Also i've explored different options of gedit but still no luck.
When I run "gedit /usr/local/share/SomeFolder/Readme.txt" from terminal it opens only one instance and that of the Readme.txt file.
Maybe gedit is programmed to behave this way or I am doing something wrong.
Any help will be appreciated.
I am using Ubuntu 12.04 LTS,64 Bit with Eclipse Juno SR2 (JDK 1.7u51)
Thanks !
Try this, i just tested using ProcessBuilder