• Post Reply Bookmark Topic Watch Topic
  • New Topic

Open "vi" Editor from java  RSS feed

 
Raed Qudaisat
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
Plz I need your help;;;
I am writing a java programe that has to open the "vi" editor, on linux Operating System..

I tried this code
Runtime.getRuntime().exec("vi test.txt");

but it didn't work,,

Any idea plz???
 
Scott Selikoff
author
Bartender
Posts: 4093
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What was the output? It should have opened it somewhere, maybe you're not seeing it.
 
Henry Wong
author
Sheriff
Posts: 23292
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The way it is executed, it may not have opened anywhere. To do that, you need to execute a shelltool or xterm first -- which then can run the "vi" command.

Henry
 
Raed Qudaisat
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Henry Wong:
The way it is executed, it may not have opened anywhere. To do that, you need to execute a shelltool or xterm first -- which then can run the "vi" command.

Henry


thanx for answering,,
what do you mean by you need to execute a shelltool or xterm first???

any example code plz???

I'm writing a console application that draw a screen and show all of it's contents files "available files" the user will choose the wanted file with arrows,, and when his/her wanted file is highlighted he can press return "enter" to open his/her file with the "vi" editor.....

i wrote this for proop of concepts

************
Runtime rt = Runtime.getRuntime();
Process ps = rt.exec("vi test.txt");
OutputStream os = ps.getOutputStream();
InputStream is = ps.getInputStream();
DataOutputStream dos = new DataOutputStream(os);
dos.writeBytes("i");
dos.writeBytes("test");
dos.writeBytes("\u001B");
dos.writeBytes(":wq\n");
dos.flush();
ps.waitFor();
dos.close();
System.out.println(ps.exitValue());
****************
and a "test.txt" file has been created with a inner-text "test".....

i don't want to get the output stream for the Process to wrtie on the file,,, i hope if i can display it for theuser to do his/her modifications


thanx again
[ December 29, 2005: Message edited by: Raed Qudaisat ]
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!