Advices to bundle libraries with plugin

35 views
Skip to first unread message

John leger

unread,
Jul 2, 2015, 10:15:01 AM7/2/15
to icy-so...@googlegroups.com
Hi,

I put my plugin MitivDeconvolution online in beta but I have some problems and I don't really like the way I solve them. First I created two plugins: the plug-in and the library underlying with a file containing that:

public class TiPiSDK extends Plugin implements PluginLibrary{        
   
public static void main(String[] args) {        
       
System.out.println("TiPiSDK");    
   
}
}


But I need JTransforms3 as a dependency for my library (that need itself JLargeArrays) so I tried to export my project in a runnable jar with option "extract required libraries into the jar" that put JTransforms.jar and JLargeArrays.jar in my TiPiSDK.jar. But in this way Icy will never find JTransforms.
So my second solution is to export with option "package the libraries into the jar" but by doing that it will also package Icy dependencies (too heavy and redundant), so for now I remove Icy as a dependency in my eclipse project and it works (for the cost of an unsolved dependency).

It works... but the first time I download my plugin to run it, it creates a low level threading exception in Icy (cf error.txt).

So I would like to have a better support for JTransforms and for the user no exception for the first install of my plugin (after it works well).

Thank you for your suggestions.
error.txt

Stephane

unread,
Jul 3, 2015, 7:59:00 AM7/3/15
to icy-so...@googlegroups.com, johnl...@gmail.com
Hi,

In general we try to separate plugin library for plugin itself, exactly as you made !
To be perfectly modulable we would even separate the different libraries you are using (and so having a different plugin for each of them) :
- JLargeArray
- JTransform3 (with a dependance on JLargeArray)
- Your own library (with a dependance on JTransform3).

But i understand that can be a bit painful to do it this way. The easiest solution is still what you have done, actually if you unpack the JLargeArray and the JTransform3 .class files in your plugin folder, then export everything inside a single JAR file it should work perfectly. By the way, what is the difference between the JTransform included in Icy and JTransform3. Is JTransform3 backward compatible with previous version of JTransform ?

About the thread error you obtain, it's "just" a problem of EDT violation rules. Mean you are creating graphical component outside the EDT graphics thread. If you fix that, then no error message should appears. You can read this to have more understanding about the EDT stuff : https://en.wikipedia.org/wiki/Event_dispatching_thread

Hope that help !


Best,

- Stephane

John leger

unread,
Jul 3, 2015, 8:46:25 AM7/3/15
to icy-so...@googlegroups.com, johnl...@gmail.com
Hi, 

Thanks for the answer. Thats what I expected and what I will do: one plugin for each dependency.
For now with the way I do it I still have the bug:

An error occured while installing the plugin :
Fatal error while loading 'plugins.mitiv.TiPiSDK' class from plugins/mitiv/TiPiSDK.jar :
java
.lang.ClassCastException: class plugins.mitiv.TiPiSDK
Your plugin class should extends 'icy.plugin.abstract_.Plugin' class !

even if my code is:

import icy.plugin.interface_.PluginLibrary;
import icy.plugin.abstract_.Plugin;



public class TiPiSDK extends Plugin implements PluginLibrary{


   
public static void main(String[] args) {

       
System.out.println("TiPiSDK\n");
   
}
}


About JTransforms3, many things changed: the path changed, there is now dependency, so there should be 2 plugins: one for each version of jtransform.

I will do it cleanly, and we will see what happen.

Stephane

unread,
Jul 3, 2015, 9:25:14 AM7/3/15
to icy-so...@googlegroups.com, johnl...@gmail.com
Hi,

Definitely the error you got :

java.lang.ClassCastException: class plugins.mitiv.TiPiSDK
Your plugin class should extends 'icy.plugin.abstract_.Plugin' class !

Should not happen if you have this code :

public class TiPiSDK extends Plugin implements PluginLibrary {

 
...
}

So i guess something was not correctly cleaned or updated.
I let you trying to do it "cleany" and get back to me if you still experience troubles :)
Thanks for the information about JTransform3, so we can't just replace our old JTransform with the new JTransform3.

Best,

- Stephane

John leger

unread,
Jul 6, 2015, 8:55:08 AM7/6/15
to icy-so...@googlegroups.com, johnl...@gmail.com
Hi,

Now it's clean: there are four plugins and it's working well, I still have the EDT bug and will see deeper but as it does not prevent the code to run, I will think about it now.

It's just a little sad that a .jar containing another .jar is not working, but with the creation of multiple plugins it works so I think it's good because it force people to do clean things.

Anyways thanks for your help.

Stephane

unread,
Jul 6, 2015, 10:20:09 AM7/6/15
to icy-so...@googlegroups.com, johnl...@gmail.com
Hi John,

The EDT thing is related to graphical safety stuff, but if it works it's not that important to fix it.
About jar in jar, indeed it would be nice to support it and we will try to provide support for that later but actually it makes the classloader much more complexe (and slow) to handle these cases.
Anyway, glad to hear you were able to get your plugin working correctly now, well done !

Best,

- Stephane

seb

unread,
Sep 4, 2015, 4:11:18 AM9/4/15
to Icy imaging, johnl...@gmail.com
Hello!
This plugin looks awesome but why is it not available in the online plugin list (ie: in Icy menu)? 
Am I the only one to experience problem finding/downloading it?
I'm looking forward to it :)

Cheers,

Seb

John leger

unread,
Sep 4, 2015, 4:55:10 AM9/4/15
to Icy imaging, johnl...@gmail.com
Hello,

At first I was thinking to try it in beta mode, so if you want to test it just allow beta  in prefences -> Plugin -> Allow beta version. But I think that I will put it as a normal plugin very soon.

If you have some feedback, just tell me.

Thanks for your interest.

John leger

unread,
Sep 4, 2015, 5:21:46 AM9/4/15
to Icy imaging, johnl...@gmail.com
I removed the beta, so just try :)
Reply all
Reply to author
Forward
0 new messages