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