Click here to Skip to main content
15,905,144 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i need to open the default terminal in Linux from my app with command.
i use java code
this is my code but is not work

Java
String[] command = { "xterm", "ls" };
Runtime.getRuntime().exec(command);


i get this error message

Java
java.io.IOException: Cannot run program "xterm": error=2, No such file or directory

i tested on Linux Mint and Ubuntu i get the same result
Posted
Updated 18-Feb-16 17:26pm
Comments
Richard MacCutchan 31-Dec-15 11:05am    
The message "No such file or directory", should give you the clue that the system cannot find the xterm program. You probably need to give the full path.
Marwan Jabbour 31-Dec-15 11:07am    
can you give me the phat to run terminal in linux
Sergey Alexandrovich Kryukov 31-Dec-15 11:36am    
First of all, could you explain why you want to start xterm?
—SA
Marwan Jabbour 31-Dec-15 11:40am    
i need to execute command in Linux and this command need from the user interactive so i need to run the terminal with this command example of command "apt-get install app"
Richard MacCutchan 31-Dec-15 12:38pm    
That still does not make a lot of sense. Please edit your question and try and give a better explanation of what you are trying to do.

1 solution

See this...
How can I make a script that opens terminal windows and executes commands in them? - Ask Ubuntu[^]

A few things to keep in mind:
0. When you run the terminal it might close right after finishing it's work.
1. You have to make sure you have a path to the terminal in your env vars.
2. There are different terminal emulators, use the one your system has installed.

I happen to be on a Windows 7 machine right now (I can boot to Linux but I'm in the middle of backing up my disks)... this works from a cygwin terminal (mintty is the terminal emulator in cygwin): mintty &
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900