Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 708679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:25:05+00:00 2026-05-14T04:25:05+00:00

I am having a jar archive environment which is gonna call my class in

  • 0

I am having a jar archive environment which is gonna call my class in a folder like this:

java -jar "emarket.jar" ../tournament 100

My compiled class is deployed into the ../tournament folder, this command runs well.

After I changed my code to load a properties file, it gets the following exception message:

Exception in thread "main" java.security.AccessControlException: access denied (java.io.FilePermission agent.properties read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkRead(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at Agent10479475.getPropertiesFromConfigFile(Agent10479475.java:110)
at Agent10479475.<init>(Agent10479475.java:100)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at emarket.client.EmarketSandbox.instantiateClientObjects(EmarketSandbox.java:92)
at emarket.client.EmarketSandbox.<init>(EmarketSandbox.java:27)
at emarket.client.EmarketSandbox.main(EmarketSandbox.java:166)

I am wondering why this security checking will fail. I issue the getPropertitiesFromConfigFile() function inside my class’s default constructor, like this:

public class Agent10479475 extends AbstractClientAgent
{
    //default constructor
    public Agent10479475()
    {
        //set all properties to their default values in constructor
        FT_THRESHOLD                        = 400;
        FT_THRESHOLD_MARGIN                 = 50;

        printOut("Now loading properties from a config file...", "");
        getPropertiesFromConfigFile();
        printOut("Finished loading","");
        }

    private void getPropertiesFromConfigFile()
    {
        Properties props = new Properties();

        try
        {
            props.load(new FileInputStream("agent.properties"));
            FT_THRESHOLD            = Long.parseLong(props.getProperty("FT_THRESHOLD"));
            FT_THRESHOLD_MARGIN         = Long.parseLong(props.getProperty("FT_THRESHOLD_MARGIN "));
        }
        catch(java.io.FileNotFoundException fnfex)
        {
            printOut("CANNOT FIND PROPERTIES FILE :", fnfex);
        }
        catch(java.io.IOException ioex)
        {
            printOut("IOEXCEPTION OCCURED :", ioex);
        }
    }

}

My class is loading its own .properties file under the same folder. why would the Java environment complains about such a denial of access?
Must I config the emarket.client.EmarketSandbox class, which is not written by me and stored inside the emarket.jar, to access my agent.properties file?

Any hints or suggestions is much appreciated. Many thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:25:05+00:00Added an answer on May 14, 2026 at 4:25 am

    Permissions are required to access the system properties files, and your code is clearly running in a sandbox that does not grant the permission. You either need to

    • modify the sandbox security rules to allow access to that file,

    • add a specific API you can call to pass the “agent.properties” file contents, or

    • find some other way to get the properties to your code that doesn’t involve reading a file at all.

    An example of the last might to pass the properties in the file as command line arguments, or put the file into your JAR file so that you can read it as a resource (modulo the security sandbox not blocking that as well.)

    But it must be said that there is something weird about a JAR file that won’t let you read files on your own machine. Why is it doing this? Is this a homework exercise … about security managers, permissions, etc?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a compressed archive file such as application.tar.gz which has a folder application/x/y/z.jar among
I'm having some problems with some commands in Java. I created a JAR that
If I'm given two Java Libraries in Jar format, 1 having no bells and
I have developed some reusable android component which is basically a class . This
I am having trouble exporting my java project from eclipse as a jar executable
I'm having trouble retrieving 2 artifacts in my Maven/Java/Google App Engine project: com.google.appengine.orm:datanucleus-appengine:jar:1.0.7.final com.google.appengine:appengine-api-1.0-sdk:jar:1.3.4
I am having a problem producing a working jar file. I would like to
I am having trouble correctly generating a Jar for my Java implementation. I am
I am having trouble trying to use an imported class from a jar file
Is it possible to run java -javaagent:myagent.jar some.package.Main without having agent packaged to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.