Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-17-2009, 12:54 PM
Member
 
Join Date: Apr 2009
Posts: 17
Rep Power: 0
jasmu is on a distinguished road
Default Java in MAC OS
Hai,

I am trying to create a application file in mac, using the below code.

Code:
FileOutputStream fout;	
try		
{		   
 fout = new FileOutputStream("/Users/laserwords/Desktop/fileopening.app");   		
  new PrintStream(fout).println ("tell application \"Finder\" \n set myFil to \"Macintosh HD:sample1.pdf\" as string	open file myFil \nend tell");		 
   fout.close();		
}	
catch (IOException e)	
{	
		System.err.println ("Unable to write to file");
	
		System.exit(-1);	
}
Above mentioned application file is created, But its type is, created as
Application (Classic).

So that file is, not executable.

If we manually create, it is working properly.

Can anyone help to resolve this?

Thanks in advance.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 04-17-2009, 07:18 PM
Senior Member
 
Join Date: Nov 2008
Posts: 275
Rep Power: 2
neilcoffey is on a distinguished road
Default
I can tell you a couple of things wrong with your Java code, but I don't know that it's what's causing the problem. You may need to ask on a specifically Mac forum too.

When you wrap one stream around another-- as you're doing with your PrintStream around a FileOutputStream, you need to close the last stream you created. So in this case, the thing you should be closing at the end is the PrintStream, not fout.

In genearlly, you should also close that stream in a finally clause, although for a throwaway bit of code, that's not crucial.

I basically know nothing about Macs, but one thing that occurs to me: do you need to chmod the file you've created to give it execution access, or is the desktop environment supposed to "magically" pick this up from the file extension?
__________________
Neil Coffey
Javamex - Java tutorials and performance info
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



All times are GMT +2. The time now is 11:44 AM.



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