Jump to content

Working in multiple files. Blocked Permission: accessClassInPackage.com.sun.activation.registries


dc0qdguZU8R50JJu

Recommended Posts

Note: new to Java programming; not new to programming in general.

So my scripts are getting longer and more complex, therefore I am trying to store logic in different files and different classes. I feel as if I have tried every possible way, but I am getting stuck on the following error: 

Blocked permission: ("java.lang.RuntimePermission" "accessClassInPackage.com.sun.activation.registries")

I have made the following class "ExampleScript":

import generic.*;

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(author = "author", info = "info", logo = "", name = "name", version = 0)
public class ExampleScript extends Script {
    @Override
    public int onLoop() throws InterruptedException {
        Test testClass = new Test();
        testClass.testFunction();
        return random(100, 500);
    }
}

The generic package import (line 1) is a simple package I've created with therein a class called "Test" with the following code:

package generic;

import static com.sun.activation.registries.LogSupport.log;

public class Test {
    public static void testFunction() {
        log("If this would just log without a error that'd be great...");
    }
}

My file structure is as followed:

> src
    > generic
        > Test.java
    ExampleScript.java

Other notes of possible solutions I have tried:

- Having both classes in the same package; gives the same Blocked Permission error;
- Adding to my java.security the lines (see underneath);
- Re-installing Java, rebooting the client, creating new projects;
- Losing my mind :-).

Please note: I am just trying to get logic into multiple files, maybe there's a way better way of doing this in Java; let me know!

Thanks.

Just now, dc0qdguZU8R50JJu said:

Other notes of possible solutions I have tried:

Also, it is good to note that I can actually create an instance of Test, I can also log Test. However, once running the function within Test I get the error.

Link to comment
Share on other sites

Your Test class is importing a log function from a package that is blocked by OSBot's permissions.

That's not the log function you want anyway, you want the one from the OSBot API.

Remove that import and either pass an instance of MethodProvider to the constructor of your class, or have your class extend MethodProvider and call exchangeContext.

See section 5 in this tutorial:

 

Link to comment
Share on other sites

18 minutes ago, Explv said:

Your Test class is importing a log function from a package that is blocked by OSBot's permissions.

That's not the log function you want anyway, you want the one from the OSBot API.

Remove that import and either pass an instance of MethodProvider to the constructor of your class, or have your class extend MethodProvider and call exchangeContext.

See section 5 in this tutorial:

 

This was so insanely helpful. Thank you. 

Also, I had not come across that tutorial yet, so thanks for that as well. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...