Re: null pointer exception on instanciating a matlab .jar class from plugin
Posted by
Heerpa on
Jul 11, 2011; 8:20pm
URL: http://imagej.273.s1.nabble.com/null-pointer-exception-on-instanciating-a-matlab-jar-class-from-plugin-tp3683949p3683965.html
Hey Johannes,
>> >> java.lang.UnsatisfiedLinkError: Native Library C:\Program
>> >> Files\MATLAB\R2007a\bin\win32\nativemcl76.dll already loaded in
>> another
>> >> *classloader*
>
>> > Is it possible that I implicitely load the dll twice in the
>> *plugin*?
>
>> Must be that.
>
> I remembered today that I have copied the javabuilder.jar to the
> src directory of the project (and later into the plugins dir of IJ
> as directed by the IJ-plugin Netbeans tutorial linked to above) as
> well as specified the classpath in the project properties to be
> C:\Program Files\MATLAB\MATLAB Component Runtime\v76\toolbox
> \javabuilder\jar\javabuilder.jar
>
> Perhaps the problem is that there are those two same .jars?
> When I compile my .java from within IJ, I do not set any classpath
> (is it possible to do this? or put it as code into the .java
> file?), though - so it should only use the one I copy into the
> plugins folder.
> Is the classpath stored into the .class when compiling in netbeans?
> because if not, that would possibly explain why it does work when I
> run an application using my matlab jar from netbeans whereas I get
> this null pointer when running it from IJ.
To analyze this, I tried to call the javaapplication using the matlab-
jar from the command line instead of netbeans. I thought that maybe
there are special arguments you had to pass for it to work. There I
saw that I had to call
java javaapplication1 -fork="true"
so I had to create a new JVM for the call. Otherwise it would give a
null pointer exception at the same line (although it didn't mention
the dll). So I imagine that this might be the problem in IJ, too. Do
you know whether it is possible to make ImageJ call the plugin with
that argument?
Best, Heinrich