Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-07-2008, 03:53 AM
Member
 
Join Date: Oct 2008
Posts: 1
Rep Power: 0
Pesch is on a distinguished road
Default Opening Text Files with Default System Editor
Is there a platform independent way to open a text file using the default system text editor?

Barring that, how difficult would it be to set up some swing components to display text files? I have very little experience with GUI programming or Swing.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 10-07-2008, 04:24 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 6,525
Rep Power: 9
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Originally Posted by Pesch View Post
Is there a platform independent way to open a text file using the default system text editor?
First of all you have to find what is the default text editor is. I think on Windows it's Notepad. So you can use Runtime class, with Notepad.exe. For Linux and UNIX systems there is a common way to do it. Just Google it, I'm not remember what it is. Anyway you have to use the Runtime class there too.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 10-07-2008, 05:06 AM
Senior Member
 
Join Date: Jun 2008
Posts: 902
Rep Power: 2
masijade is on a distinguished road
Default
If you have 1.6 or later, read the API docs for the Desktop class and it's open method.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 10-07-2008, 01:50 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Rep Power: 4
Norm is on a distinguished road
Default
It is dependant on the OS and on how a user has tailored his system. I'm on XP and I've set Wordpad to open when I click on a .txt file.
In windows there is an OS command that will lookup the default command to use when opening a file. However I think its different on different versions of windows. For some it's CMD and for others its COMMAND.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 10-08-2008, 08:58 AM
fishtoprecords's Avatar
Senior Member
 
Join Date: Jun 2008
Posts: 571
Rep Power: 2
fishtoprecords is on a distinguished road
Default
Originally Posted by Norm View Post
For some it's CMD and for others its COMMAND.
I thought it was "COMMND" but that was long ago.

Its been CMD in Windows 32 bit always. From NT 3.1 on.

If you are still running Win16 (windows 95, Win98, WindowsME) then its still COMMAND (or COMMND) but no one should be using those things. They are from last century.

Back on topic, the reason that java 1.6 has the Desktop stuff is that without it, you can't do it transparently without all sorts of OS specific voodoo
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 10-08-2008, 06:17 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Rep Power: 4
Norm is on a distinguished road
Default Where does Java find the "user-default' programs?
I just tried the DesktopDemo program from the Java Tutorial and find that it does NOT use my defauts. I've tailored my system changing MS's defaults to what I like. For example, DC on a .html file starts Firefox. DC on a .txt file starts Wordpad.
In the DesktopDemo program, it started IE for a .html file and Notepad for a .txt file. Those are NOT my defaults.

Where does the JVM look to find the "user-default" programs? I would assume on Windows it'd look in the registry. It obviously doesn't use the same path as a user can to set the defaults: Tools|Folder Options|File Types|Registered Filetypes ...

Thanks,
Norm
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Default/System Date Format Pattern? Gajesh Tripathi AWT / Swing 1 10-05-2008 07:34 AM
opening jar files on pc prepared by mac willemjav Advanced Java 42 09-27-2008 05:53 PM
Invoking the system text editor on autoexec.bat Java Tip SWT 0 07-25-2008 02:32 PM
SWT Text Editor Java Tip SWT 0 07-07-2008 04:43 PM
Linking files with Editor JavaForums Java Blogs 0 05-21-2008 10:00 PM


All times are GMT +2. The time now is 12:36 AM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org