Skip to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

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.

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:

 

  • Author
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. 

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.