My Situation Is: I am trying to make a simple IDE for NASM in Java. When I execute a .asm file in my IDE it open the terminal and shows the output. I am using xterm for this purpose. Now the problem is I really don't like the look of xterm or uxterm. I prefer the gnome-terminal. But if I use the gnome-terminal this will restrict my application to a particular OS i.e. it will be able to execute .asm files only in Ubuntu (for eg:the default terminal for KUbuntu is something else.. etc.. )

So my idea is that if there is a 'command' that i can run in xterm to get to know the default terminal and execute the .asm files via my application in the default terminal of the particular OS. That was my first question.

My second question is: Is there a way i can simply transfer the controls of a terminal to something else. Like in Java to a JTextPane. My idea is to simply create a console like in ecplipse of netbeans where you can see your output in their own console. So It will be actually better than the idea of invoking the terminal and then running the commands in it.


x-terminal-emulator is rigged up as part of the alternatives system to call an available terminal.

Note that this is system-wide and not a desktop-specific thing so it could mean that Gnome Terminal runs on KDE if both it and Konsole are installed... But it's close enough IMO.

I've also found that there's a $COLORTERM environment variable defined. On this Kubuntu machine —without gnome-terminal installed— it's still set to Gnome Terminal. So perhaps not that reliable.

  • Yes, but that will not work on Fedora or other .rpm systems and I think the OP wants maximal portability. – Panther Jun 13 '14 at 15:33
  • 1
    Welcome to Ask Ubuntu :) – Oli Jun 13 '14 at 15:34
  • That reads snarkier than intended. I'm just not used to needing to be cross-platform. This should work on all flavours of Ubuntu. – Oli Jun 13 '14 at 15:40
  • I understand. If the op really wants cross platform compatibility probably best to ask on unix.stackexchange.com/questions – Panther Jun 13 '14 at 16:35
  • I do want cross platform compatibility. But the thing is I want to somehow redirect the output from the terminal(let it be xterm) to my own console. So in this case evn if I am executing my program in xterm It wont matter cause ill redirect the data or whatever is being displayed in the xterm to my own console. I tried googling but couldnt find anything. Maybe i am not doing it right. I searched for a API but there was none that could do it. So maybe Ill have to do it on my own. Please help! – amitection Jun 14 '14 at 17:15

You can call a terminal with "x-terminal-emulator" , see http://crunchbang.org/forums/viewtopic.php?id=13945

Alternately, if you want maximal portability, write a set of tests to determine the available terminals, set a variable TERMINAL and then call TERMINAL from within your script.

  • I see what you are trying to say. I could use exception handling for that purpose. But as there are many OS's going through each to check for the correct(or rather default) terminal would slow down the process. – amitection Jun 14 '14 at 17:20
  • Not really, there are only really 3 or 4 terminals to check for and fall back to xterm. – Panther Jun 14 '14 at 17:32
  • Ill Try what you are saying and will get back to you when its done.. but is there by any chance that you know how these IDE's like Netbeans and Eclipse have their own console. I mean how do they run the programs on their console.. – amitection Jun 14 '14 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.