Print at Dec 20, 2025, 12:00:14 PM

Posted by clanmills at Mar 2, 2015, 5:07:10 PM
How to load "foreign" jars from a Plugin?
Folks

I've written a Plugin that uses 3 other jars.

-rw-r--r--@ 1 rmills staff 23K 21 Jan 13:52 json-simple-1.1.1.jar
-rw-r--r--@ 1 rmills staff 23K 15 Jan 11:44 simple.jar
-rw-r--r--+ 1 rmills staff 312K 28 May 2014 ST-4.0.8.jar

When I execute SH3D on Eclipse, everything is working OK (Mac/Windows/Linux).

However, I'm wondering how to deploy this on a user's computer. On the Mac, I've added <string>path-to-jar</string> to <SH3D>.app/Contents/Resources/Info.plist in <key>ClassPath</key><array>...</array> On Linux, I've modified the -classpath argument in the script SweetHome3D. I've given up on Windows, although it's working from Eclipse. Of course, I don't expect users to modify those files. I've done that to debug my code.

The question is: Is there a directory into which jars should be added for use by plugins?

I've looked at the APIs in Java and I believe URLClassLoader will solve this issue. Before I hurt my head getting that to work, I wondered if there's something already in SW3D to handle this.