Page 1 of 2 12 LastLast
Results 1 to 20 of 22
Like Tree2Likes

Thread: getting error when applet try to access some jar file

  1. #1
    anchitanc is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default getting error when applet try to access some jar file

    hi all

    i am running applet in browser and i am getting error :-


    Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission getenv.mywork)
    at java.security.AccessControlContext.checkPermission (Unknown Source)
    at java.security.AccessController.checkPermission(Unk nown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.System.getenv(Unknown Source)
    at com.fame.timeiq.license.LicenseCheck$LicenseFileLo cation.<init>(SourceFile:828)
    at com.fame.timeiq.license.LicenseCheck.l(SourceFile: 589)
    at com.fame.timeiq.license.LicenseCheck.a(SourceFile: 522)
    at com.fame.timeiq.license.LicenseCheck.a(SourceFile: 370)
    at com.fame.timeiq.dates.RegularCalendar.<clinit>(Sou rceFile:108)

    here "mywork" is api and have some classes which are using in my program and i put this jar file in system environment variable also (environment variable name is "mywork")

    and i modify java.policy file also :-
    permission java.lang.RuntimePermission "getenv.*";
    permission java.lang.RuntimePermission "getenv.","*";
    permission java.lang.RuntimePermission "*", "read,write";
    permission java.lang.PropertyPermission "*", "read,write";

    but still its not working

    thanks in advance

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,165
    Rep Power
    20

    Default Re: getting error when applet try to access some jar file

    Why are you trying to access a jar file on the client system?
    Your applet tag should reference any dependent jars, and those jars should be in the same location as the applets application jar (or classes).

  3. #3
    anchitanc is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default Re: getting error when applet try to access some jar file

    thanks for reply tolls :)
    my jar file is some product which is doing some operation .... and yes i am trying to access those jar on client system only

    here in error "mywork" is a product( so i put it on system environment variable also) by using "mywork" i make application which are normal graphical application but now i like to run that application in applet. mywork is just collection of API

    please help me

    thanks
    Last edited by anchitanc; 12-23-2011 at 03:41 PM.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,165
    Rep Power
    20

    Default Re: getting error when applet try to access some jar file

    As I said, applets should have everything they need listed with the applet tag, and located with the applet on the server.
    They should not be attempting to access additional jar files located on the client outside those in the JRE itself.

  5. #5
    anchitanc is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default Re: getting error when applet try to access some jar file

    yes, i put all required jar file in applet tag

    but i am asking is there any way to access all jar which are outside jre or classpath by making some change in policy file or something else

    thanks

  6. #6
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,755
    Rep Power
    25

    Default Re: getting error when applet try to access some jar file

    is there any way to access all jar which are outside jre or classpath by making some change in policy
    Are all the jar files together on the server? What does your archive= attribute look like? Does it list all of the jar files?

    i modify java.policy file also
    The filename on my system is: .java.policy
    Notice the leading .

  7. #7
    anchitanc is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default Re: getting error when applet try to access some jar file

    Quote Originally Posted by Norm View Post
    Are all the jar files together on the server? What does your archive= attribute look like? Does it list all of the jar files?


    The filename on my system is: .java.policy
    Notice the leading .
    <applet code="SampleApplet" archive="./lib/test1_Test.jar,./lib/mywork.jar,./lib/myworkLicense.jar,height="400" width="600">

    and here sampleapplet in "test1_Test.jar" file and this class is using mywork.jar this actually is a product of my company which we use to perform some operation and we put this product in ystem environment variable also with mywork name. and i am getting this error ---- Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission getenv.mywork)

    mywork is API have some classes

    C:\Program Files\Java\jdk1.6.0_13\jre\lib\security inside this java.policy is located
    some suggested me that after making change in this file u can access all jar file at runtime so i put permission java.lang.RuntimePermission "getenv.*"; this in java.policy file

    please help me

    thanks for reply norm

  8. #8
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,755
    Rep Power
    25

    Default Re: getting error when applet try to access some jar file

    I don't change files in the jre/jdk folders. I use the one referred to by the following:
    If you look in the java.security file there is this reference to where the .java.policy file should be:

    # The default is to have a single system-wide policy file,
    # and a policy file in the user's home directory.
    policy.url.1=file:${java.home}/lib/security/java.policy
    policy.url.2=file:${user.home}/.java.policy <<<<<<<<<<<<<<<< THIS IS THE ONE I've USED

    My .java.policy file is in:
    C:\Documents and Settings\Norm\.java.policy

    The no codebase section:

    grant {
    permission java.lang.RuntimePermission "modifyThread";
    permission java.util.PropertyPermission "*", "read";
    permission java.lang.RuntimePermission "modifyThreadGroup";
    permission java.io.FilePermission "E:\\Java\\Java-1_6_0\\docs", "read";
    permission java.io.FilePermission "F:/Java/Tutorial_6/tutorial/", "read";
    };

  9. #9
    anchitanc is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default Re: getting error when applet try to access some jar file

    Quote Originally Posted by Norm View Post
    I don't change files in the jre/jdk folders. I use the one referred to by the following:
    If you look in the java.security file there is this reference to where the .java.policy file should be:

    # The default is to have a single system-wide policy file,
    # and a policy file in the user's home directory.
    policy.url.1=file:${java.home}/lib/security/java.policy
    policy.url.2=file:${user.home}/.java.policy <<<<<<<<<<<<<<<< THIS IS THE ONE I've USED

    My .java.policy file is in:
    C:\Documents and Settings\Norm\.java.policy

    The no codebase section:

    grant {
    permission java.lang.RuntimePermission "modifyThread";
    permission java.util.PropertyPermission "*", "read";
    permission java.lang.RuntimePermission "modifyThreadGroup";
    permission java.io.FilePermission "E:\\Java\\Java-1_6_0\\docs", "read";
    permission java.io.FilePermission "F:/Java/Tutorial_6/tutorial/", "read";
    };

    i am using windows 7

    second url file is not visible to me ....

    u mean to say i need to modify that file

  10. #10
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,755
    Rep Power
    25

    Default Re: getting error when applet try to access some jar file

    I use the policytool.exe that comes with the jre to edit the file. The first time, before the file exists, you need to set the path to the file when you save it.

    I have done it on Windows 7 and XP.

  11. #11
    anchitanc is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default Re: getting error when applet try to access some jar file

    when i googled it i got... i need to make signed jar or signed applet for that. shuold i try those thing ???? i seen this thing is so complex to implement

    thanks

  12. #12
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,755
    Rep Power
    25

    Default Re: getting error when applet try to access some jar file

    If all the files are on the one PC where you execute the applet, then you can change its .java.policy file and get it to work. I have several applets I use on my PC that work with the changes I've made to the policy file.
    If there is more than one PC involved, then you either need to change ALL of their .java.policy files or sign the applet/jar files.
    anchitanc likes this.

  13. #13
    anchitanc is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default Re: getting error when applet try to access some jar file

    Quote Originally Posted by Norm View Post
    The first time, before the file exists, you need to set the path to the file when you save it.
    i didnt get this line .....so this tool modify which file or how its work

    thanks norm

  14. #14
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,755
    Rep Power
    25

    Default Re: getting error when applet try to access some jar file

    the policytool is a special editor for the .java.policy file.
    When you are done making changes to the policy file you need to Save it.
    anchitanc likes this.

  15. #15
    anchitanc is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default Re: getting error when applet try to access some jar file

    Quote Originally Posted by Norm View Post
    the policytool is a special editor for the .java.policy file.
    When you are done making changes to the policy file you need to Save it.

    thanks you very very very much norm

  16. #16
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,755
    Rep Power
    25

    Default Re: getting error when applet try to access some jar file

    You're welcome.

  17. #17
    anchitanc is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default Re: getting error when applet try to access some jar file

    hi norm,

    i sign the applet but it working fine in appletviewer but it not working in browser like - applet is visible not working.
    my applet is using some .jar files so so i need to sign all the jar file which are in use with applet ?????

    please help me out

    thanks

  18. #18
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,755
    Rep Power
    25

    Default Re: getting error when applet try to access some jar file

    it not working
    What errors do you get?
    Can all the class files be put into one jar and sign that jar?

  19. #19
    anchitanc is offline Member
    Join Date
    Oct 2010
    Posts
    44
    Rep Power
    0

    Default Re: getting error when applet try to access some jar file

    i norm thanks for reply
    now its working fine.
    first i put all jar files in one jar that time its not working
    but now i signed each jar separately in that case its working fine

    thanks norm ones again

  20. #20
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,755
    Rep Power
    25

    Default Re: getting error when applet try to access some jar file

    Glad you got it working.

Page 1 of 2 12 LastLast

Similar Threads

  1. Error while Running the Applet from JAR file
    By rameshiit19 in forum Java Applets
    Replies: 0
    Last Post: 07-27-2011, 02:38 PM
  2. Error when trying to view applet in a .htm file
    By deapee in forum New To Java
    Replies: 7
    Last Post: 06-20-2011, 05:55 AM
  3. Replies: 6
    Last Post: 02-10-2011, 10:55 AM
  4. file access from applet
    By Ranu in forum New To Java
    Replies: 11
    Last Post: 07-29-2010, 07:37 AM
  5. data file Access from applet
    By Ranu in forum New To Java
    Replies: 3
    Last Post: 07-28-2010, 09:11 AM

Posting Permissions

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