Xcode Java Java.util.PropertyPermissions user.dir.read

Discussion in 'Mac Programming' started by m3the01, Jul 11, 2007.

  1. macrumors member

    Joined:
    Jun 18, 2007
    #1
    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
     
  2. thread starter macrumors member

    Joined:
    Jun 18, 2007
    #2
    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
     
  3. macrumors 6502a

    Joined:
    Sep 3, 2005
    Location:
    Cramlington, UK
    #3
    Hi
    I'd be happy to try it on my Mac if you zip a test project.

    b e n
     
  4. macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #4
    code might help
     
  5. thread starter macrumors member

    Joined:
    Jun 18, 2007
    #5
    Custom app for profit, lol.

    I can make a small app to demo,

    Hold on,

    Steven
     
  6. thread starter macrumors member

    Joined:
    Jun 18, 2007
    #6
    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
     

    Attached Files:

  7. macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #7
    FileChooser line 25: You shouldn't rely on environment variables, especially for path names.

    Instead of $home, try using
    Code:
    System.getProperty("user.home")
     
  8. thread starter macrumors member

    Joined:
    Jun 18, 2007
    #8
    Yeah i tried that earlier but no luck,

    Any other suggestions?

    Works perfect outside of xcode
     
  9. macrumors 6502a

    Joined:
    Sep 3, 2005
    Location:
    Cramlington, UK
    #9
    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
     
  10. thread starter macrumors member

    Joined:
    Jun 18, 2007
    #10
    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.
     
  11. macrumors 6502a

    Joined:
    Sep 3, 2005
    Location:
    Cramlington, UK
    #11
    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
     
  12. macrumors 6502a

    Joined:
    Sep 3, 2005
    Location:
    Cramlington, UK
    #12
    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
     
  13. thread starter macrumors member

    Joined:
    Jun 18, 2007
    #13
    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
     
  14. macrumors 6502a

    Joined:
    Sep 3, 2005
    Location:
    Cramlington, UK
    #14
    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
     

Share This Page