Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-07-2008, 05:53 AM
Member
 
Join Date: Oct 2008
Posts: 1
Pesch is on a distinguished road
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
Sponsored Links
  #2 (permalink)  
Old 10-07-2008, 06:24 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,412
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Quote:
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.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
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.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 10-07-2008, 07:06 AM
Senior Member
 
Join Date: Jun 2008
Posts: 443
masijade is on a distinguished road
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, 03:50 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Gone to Costa Rica
Posts: 2,223
Norm is on a distinguished road
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, 10:58 AM
fishtoprecords's Avatar
Senior Member
 
Join Date: Jun 2008
Posts: 462
fishtoprecords is on a distinguished road
Quote:
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, 08:17 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Gone to Costa Rica
Posts: 2,223
Norm is on a distinguished road
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
Sponsored Links
Reply


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

vB 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 09:34 AM
opening jar files on pc prepared by mac willemjav Advanced Java 42 09-27-2008 07:53 PM
Invoking the system text editor on autoexec.bat Java Tip SWT 0 07-25-2008 04:32 PM
SWT Text Editor Java Tip SWT 0 07-07-2008 06:43 PM
Linking files with Editor JavaForums Java Blogs 0 05-22-2008 12:00 AM


All times are GMT +3. The time now is 04:44 PM.


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