Results 1 to 2 of 2

Thread: Java in MAC OS

  1. #1
    jasmu is offline Member
    Join Date
    Apr 2009
    Posts
    17
    Rep Power
    0

    Default Java in MAC OS

    Hai,

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

    Java 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.

  2. #2
    neilcoffey is offline Senior Member
    Join Date
    Nov 2008
    Posts
    286
    Rep Power
    6

    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?

Posting Permissions

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