Find the answer to your Linux question:
Results 1 to 7 of 7
Hi to all, this is my first forum, I'm doiing a project in java using swing with NetBeans IDE, in that i've a JButon, when is click the a Text ...
  1. #1
    Just Joined!
    Join Date
    Feb 2008
    Posts
    4

    Smile how to open Text File(Notepad in windows os ) in linux

    Hi to all, this is my first forum,

    I'm doiing a project in java using swing with NetBeans IDE, in that i've a JButon, when is click the a Text File should be Opened. how can i do this . In windows os i can give the code like this..
    Runtime.getRuntime().exec("notepad");



    The same way how can i open the Text File application (as notepad in windows) in SUSE Linux and also calculator.

    Help me Plz..
    Thanks in Advance...

  2. #2
    Just Joined!
    Join Date
    Feb 2008
    Posts
    34
    I'm not sure, but is there a reason that you cannot just right click the file and click open with "text editor"?

    Also, in GNOME the calculator can be opened by going to Applications>accessories>Calculator.

    Are you running SUSE with KDE or GNOME. If you are unsure, does your computer open the file manager with Konquerer or Nautilus?

  3. #3
    Just Joined!
    Join Date
    Feb 2008
    Posts
    4

    Smile how to open Text File(Notepad in windows os ) in linux

    I'm using SUSE with KDE. Actually my question is, i've a JButton ( named as "open Text File" )in my application or project , when i click the button a Text File will have to open, but not like this Applications>accessories>Calculator. OR using shell editor how can i open a Text File...

    where i can find the calculator and Text file folder or path in linux as exe
    Thanks ..

  4. #4
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    well there are a couple of "standard" editors in linux but not necessarily everyone will have them, like in windows everyone has notepad

    you could do this in a few ways, you could ask them what editor they want via a prompt where they type the path to it, or browse to it, or you could check for the most common editors and ask which they'd prefer to use and let them browse to another if it isn't in the list you found

    you could also open up the text file in a text pane type window and let them edit it from there, that way you wouldn't have to open a specific editor for it, and provide a save button or whatever else you needed

  5. #5
    Just Joined!
    Join Date
    Feb 2008
    Posts
    34
    Quote Originally Posted by vegam_smart View Post
    I'm using SUSE with KDE. Actually my question is, i've a JButton ( named as "open Text File" )in my application or project , when i click the button a Text File will have to open, but not like this Applications>accessories>Calculator. OR using shell editor how can i open a Text File...

    where i can find the calculator and Text file folder or path in linux as exe
    Thanks ..
    Linux doesn't use exe's actually. It really doesn't rely that much on file extensions, they are mostly for the user. If you want to open a program, the easiest way to do it is to open the terminal and type in "kwrite" or "gedit" to open the text editor. so say you want to open foo.txt in your home folder:
    Code:
     kwrite foo.txt
    I hope that answers that question, but i dont know what a Jbutton is!

  6. #6
    Linux Guru techieMoe's Avatar
    Join Date
    Aug 2004
    Location
    Texas
    Posts
    9,496
    Quote Originally Posted by vegam_smart View Post
    I'm using SUSE with KDE. Actually my question is, i've a JButton ( named as "open Text File" )in my application or project , when i click the button a Text File will have to open, but not like this Applications>accessories>Calculator. OR using shell editor how can i open a Text File...

    where i can find the calculator and Text file folder or path in linux as exe
    Thanks ..
    I assume from your mentioning a JButton that you're trying to launch a native program from inside a Java program? You'll need to look at the Runtime.exec() method.

    Runtime (Java 2 Platform SE v1.4.2)
    Execute an external program - Real's Java How-to

    As far as the full path, that shouldn't be necessary. Just find the name of a text editor you have installed and pass that command to the exec(). If you want to use the shell you can use any number of standard editors: nano, emacs, vi.
    Registered Linux user #270181
    TechieMoe's Tech Rants

  7. #7
    Just Joined!
    Join Date
    Mar 2008
    Posts
    6
    The usual thing on Linux is to look at the EDITOR environment variable to see if the user has specified an editor (use System.getenv("EDITOR")). If so, pass the resulting string to exec(). Otherwise fall back to "vi". If I was using your program, that's the behaviour I'd expect.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...