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

m3the01

macrumors member
Original poster
Jun 18, 2007
70
0
Hey Guys and Gals,

Happens only under xcode, if i run from the terminal everything is fine.

I assume there is an option somewhere that i could set within xcode but can find any info anywhere.

Just attempting to open a JFileChooser when this exception is thrown.

Access Denied(Java.util.PropertyPermission) user.dir read

thanks
 

m3the01

macrumors member
Original poster
Jun 18, 2007
70
0
I really cant believe im the only person ever to use xcode and a JFileChooser.

I cant find any info on importing policy files, anything. Its a simple read, not even trying to write.

Arggg, really annoying.

Steven
 

m3the01

macrumors member
Original poster
Jun 18, 2007
70
0
Custom app for profit, lol.

I can make a small app to demo,

Hold on,

Steven
 

m3the01

macrumors member
Original poster
Jun 18, 2007
70
0
Here we go,

Xcode project that duplicates the error, sorry i was in a rush.

I couldnt get the whole thing under the 244kb max so there are 4 small jave files, i guess just create a new xcode project and add them manually.

Sorry for the troubles. I tried combining them all in one file, but always like 3mb.

Arrggg.

thanks again
 

Attachments

  • Test.zip
    2.4 KB · Views: 149

jeremy.king

macrumors 603
Jul 23, 2002
5,479
1
Holly Springs, NC
FileChooser line 25: You shouldn't rely on environment variables, especially for path names.

Instead of $home, try using
Code:
System.getProperty("user.home")
 

m3the01

macrumors member
Original poster
Jun 18, 2007
70
0
Yeah i tried that earlier but no luck,

Any other suggestions?

Works perfect outside of xcode
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
Looks to me like you need to set the Java policy for the applet. Running it from the command line and running it as an applet are different things.

Hope this helps

b e n
 

m3the01

macrumors member
Original poster
Jun 18, 2007
70
0
I hear u, but the big question is how in the world to do this through xcode?

I tried just throwing a policy file in the directory but no luck.
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
Look at this link

I just tried it and I managaed to get you test app to work. Basically you need to create a .java.policy file in your home directory and assign your app the relevant permissions. If you're like me and lazy just assign it all permissions.

If you plan on distributing something then you'll need to sign your app. I don;t know how you do that though.

b e n
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
Your .java.policy file in your home directory would have an entry looking something like this:-

grant codeBase "file:///Users/ben/path-to-project/build/Debug/project-name.jar" {
permission java.security.AllPermission;
};



b e n
 

m3the01

macrumors member
Original poster
Jun 18, 2007
70
0
Hey Lazy Dog thanks for the help,

I tried including the policy file in the directory for the app, nothing worked.

Thanks for the suggestion to put in the home directory works perfect now,

So why is it that i dont need to do this on any of my linux build, windows and such?

thanks again,

Steven
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
I'm not sure… are you sure you can run your app from a browser on Linux and Windows? I'm not even remotely an expert on this sort thing but I suspect it has something to do with the default policies, ie OS X is more cautious than Linux or Windows?

b e n
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.