ScriptCraft

ScriptCraft

14.6k Downloads

Using external jars

demipixel opened this issue ยท 4 comments

commented

It'd be very helpful to be able to use existing java libraries/apis.

Is there any way to do this? I've tried stuff like adding to the scriptcraft.jar, and adding it to /lib and build.xml and recompiling the plugin. Is there a way to do this so I can access jars through Packages.path.to.the.package? Currently I'm specifically attempting to use jedis but it'd be nice to have a universal way to do this.

On a similar note, would SC ever support a way of doing this by simply dragging a jar into one of it's folders? Maybe an external folder?

Similar to #320 however it's more based around Java jars than JS, and seems like it may have an easier solution.

commented

So it seems I can achieve what I'm looking for with URLClassLoader. Not in my opinion the cleanest way, but better than nothing! I'm gonna close this unless anybody has any better/cleaner ways to do this.

commented

External jars can be used by including them in the classpath when starting the server.
For example - see https://github.com/walterhiggins/scriptcraft-extras-mqtt#to-use

commented

Thank you :)

commented

Sounds like a fun challenge. It should be doable to load jars and call them via javax.script.ScriptEngne . I think it would need some kind of security system though (if you allow the users to upload jars).