This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in opening a file in mac  RSS feed

 
Kushagra Bindal
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am using Runtime.getRuntime().exec("open "+"fileName");. And it is working fine when there is no space in file or folder name .
But the application got crashed when I am trying to open a file with space in iots name.
Please suggest me what I have to do in that case.

Thanks
Kushagra
 
Kushagra Bindal
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any body please help me as I am in urgent need of some solution.

What I have done on window is to put the file name in"" and then process on it and its working fine there but the same is not working on mac.

Please suggest me the best possible solution.

Thanks
Kushagra
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Patience Is A Virtue.
 
Carey Evans
Ranch Hand
Posts: 225
Debian Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the other versions of Runtime.exec(), and you’ll find one that works better if you want to keep the filename separate from the command.
 
Kushagra Bindal
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for your prompt reply.

But actually I have used many of them and still no progress in the same.

As I told earlier that doc is opening fine when there is no space in file/folder. But creating problem in opening on mac. But the is working fine when I use the same code(Runtime.exec) for window.

One more thing I want to ask is that is it possible with the help of Runtime.exec to open the file in background or simply minimize it while opening the doc. This I am serching for both mac and window.

This will be very helpful for me if any one give me some hint or solution for the same.

Thanks
Kushagra
 
Kushagra Bindal
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Please suggest any way to open the word doc on Mac as I have to demonstarte the same.

Thanks
Kushagra
 
Kushagra Bindal
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Please suggest me what I have to do as for the filename having space between their name I replaced them with the "file name". So that it will be treated as a single file. And the same code working fine on winsow and also on mac for a file with no space. But For files with space it is not opening the files.

Thanks
Kushagra
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure why it isn't working, but you can resort to one of Apple's Java extensions: The com.apple.eio.FileManager class and its openURL(String) method. (You will need the Apple Java Extensions library in your classpath if you want to compile code using this class on non-OS X machines.)

The http://faq.javaranch.com/java/MacOsxFaq links to the download and the javadocs, as well as to "Tailoring Java Applications for Mac OS X" and "Apple OSXAdapter" both of which you may want to peruse in order to make Java applications more Mac-like.
 
Kushagra Bindal
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

There are lots of many links there on the link provided by you. Out of which which should I use.

Thanks
Kushagra
 
Kushagra Bindal
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I gothe Java Extension class
Thanks for the help

Let me try the solution.

Kushagra
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!