Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

chidambaram

macrumors member
Original poster
Mar 9, 2008
67
0
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.
 

dr-jerry

macrumors newbie
Apr 15, 2009
9
0
a stacktrace.

How do you manually create it? I assume you need to set the umask to the file or even set some attributes to it.
Ast this is mac specific java may not be the right choice to create those files, as the option should also be avaible on windows.

plz ignore previous post as it was a matter of not reading the question..
j.
 

dr-jerry

macrumors newbie
Apr 15, 2009
9
0
Giving it a second or rather third thought:
grab a terminal, cd to the directory you're manuall creating the file in. And do a
Code:
ls -l@
(assuming you're doing leopard).
You than need to figure out how to get java created file, have the same umask and attributes as the manually created file.
You than should use java.lang.Runtime to modify this file.
Hope this helps.
 

chidambaram

macrumors member
Original poster
Mar 9, 2008
67
0
I open the script editor, Typed this

Code:
tell application "Finder" 
 set myFil to "Macintosh HD:sample1.pdf" as string
open file myFil end tell

Saved this as,
fileopen.app


If i double click the file "fileopen.app", it will open ,sample1.pdf

it is just like a bat file in Windows.
 

wrldwzrd89

macrumors G5
Jun 6, 2003
12,110
77
Solon, OH
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.
The problem is that AppleScripts aren't plain text, but rather a cryptic binary format.
 

chidambaram

macrumors member
Original poster
Mar 9, 2008
67
0
Thanks for your reply,

is it possible to change plain text into cryptic binary format.

So that it will be executable....
 

mufflon

macrumors 6502
Sep 15, 2006
264
2
the best alternative would be to download eclipse or netbeans, import the code and then export it as a runnable jar file with the main entry point to be the file you defined your "public static void main"... ... it'll be a .jar and not a .app, but it will do the trick and work just as well.
 

chidambaram

macrumors member
Original poster
Mar 9, 2008
67
0
Hi,

Thanks for ur reply.

Actually my requirement to open a pdf file using java program. I installed netbeans in my Mac Machine.

Without using this type of batch file ,can i open that file in any other way?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.