dc0qdguZU8R50JJu Posted December 2, 2020 Share Posted December 2, 2020 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. Quote Link to comment Share on other sites More sharing options...
Explv Posted December 2, 2020 Share Posted December 2, 2020 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: Quote Link to comment Share on other sites More sharing options...
dc0qdguZU8R50JJu Posted December 2, 2020 Author Share Posted December 2, 2020 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. Quote Link to comment Share on other sites More sharing options...