problem with using external jar-files with the "compile and run" command

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

problem with using external jar-files with the "compile and run" command

Marko Ulbrich
Hi all,


I wrote a plugin for imagej, that imports a package called "Jama-1.0.2.jar".
The import-statement is the following:
import Jama.*;

When using the ImageJ "Compile and run..." command for my plugin, I get
the following error:

------------------------------------------------------------------------
Note: sun.tools.javac.Main has been deprecated.
C:\Programme\ImageJ\plugins\Template_Matching_.java:25: Package Jama not
found in import.
import Jama.*;
        ^
1 error, 1 warning
------------------------------------------------------------------------

What can I do to use the package "Jama-1.0.2.jar".
I copied this jar-File to my imagej-directory and to the plugins-directory.

What else can I do?
Thanks, Marko
Reply | Threaded
Open this post in threaded view
|

Re: problem with using external jar-files with the "compile and run" command

Duane and Julie
Marko,

This must be your first use of an external library with Java: any jar  
files used should be in the Java path.

On Mac OSX (like my system) that's usually in ~/Library/Java/
Extensions.  On a Windoze system it's in the lib\ext directory of  
your Java installation.  If you are using the JRE that comes with  
ImageJ, it's in the lib\ext directory of that installation.

I use Jama in ImageJ plugins using the above locations without problem.

Since you ARE on Windoze (from your post), if the above locations  
can't be found, perhaps someone else on the list more familiar with  
your operating system can chime in.

Cheers,

    duane

On Jan 15, 2006, at 3:23 PM, Marko Ulbrich wrote:

> Hi all,
>
>
> I wrote a plugin for imagej, that imports a package called  
> "Jama-1.0.2.jar".
> The import-statement is the following:
> import Jama.*;
>
> When using the ImageJ "Compile and run..." command for my plugin, I  
> get the following error:
>
> ----------------------------------------------------------------------
> --
> Note: sun.tools.javac.Main has been deprecated.
> C:\Programme\ImageJ\plugins\Template_Matching_.java:25: Package  
> Jama not found in import.
> import Jama.*;
>        ^
> 1 error, 1 warning
> ----------------------------------------------------------------------
> --
>
> What can I do to use the package "Jama-1.0.2.jar".
> I copied this jar-File to my imagej-directory and to the plugins-
> directory.
>
> What else can I do?
> Thanks, Marko
Reply | Threaded
Open this post in threaded view
|

Re: problem with using external jar-files with the "compile and run" command

Robert Dougherty
In Windows, I think you are supposed to be able to add a .jar file to the
class path in the Target line of a shortcut that runs ImageJ.  It didn't
work for me; I still got "Package Jama not found in import."  Plan B was to
download the source for the Jama package to the Plugins folder.  This
produced an error I haven't seen before:

error: Invalid class file format in C:\ImageJFST\plugins\Jama\Matrix.class.
invalid constant type: 13

What I finally stumbled through is given below.  It obviously should not be
this difficult.  One thing that is probably still not right is that Matrix
has a print method that writes to System.out, and this does not seem to be
visible.

1. Download the source from http://math.nist.gov/javanumerics/jama/#Package
2. Expand and place the Jama folder in ImageJ\Plugins
3. Delete all the .class files in the top level of the Jama folder
4. Move Maths.java from Jama\util to Jama
5. Delete the Jama\util folder.
6. Edit Math.java and change "Package Jama.util;" to "Package Jama;"
7. Edit Matrix.java, EigenvalueDecomposition.java, QRDecomposition.java, and
SingularValueDecomposition.java to remove "import Jama.util.*;"
8. Create a test plugin, such as Test_Jama.java, below.
9. Start ImageJ and "compile and run" the test plugin.
   
Test_Jama.java:

import ij.*;
import ij.plugin.PlugIn;
import Jama.*;

public class Test_Jama implements PlugIn{
    public void run(String arg) {
                double[][] F = new double[3][3];
                for (int j = 0; j < 3; j++)
                        for (int i = 0; i < 3; i++)
                                F[i][j] = i+j;
                Matrix Fm = new Matrix(F);
                SingularValueDecomposition svd = Fm.svd();
                int rank = svd.rank();
                IJ.write("Rank = "+rank);
        }
}


Bob



Robert P. Dougherty, Ph.D.
President, OptiNav, Inc.
Phone (425) 467-1118
Fax (425) 467-1119
www.optinav.com
 
 

> On Mac OSX (like my system) that's usually in ~/Library/Java/
> Extensions.  On a Windoze system it's in the lib\ext directory of
> your Java installation.  If you are using the JRE that comes with
> ImageJ, it's in the lib\ext directory of that installation.
>
> I use Jama in ImageJ plugins using the above locations without problem.
>
> Since you ARE on Windoze (from your post), if the above locations
> can't be found, perhaps someone else on the list more familiar with
> your operating system can chime in.
>
> >
> >
> > When using the ImageJ "Compile and run..." command for my plugin, I
> > get the following error:
> >
> > ----------------------------------------------------------------------
> > --
> > Note: sun.tools.javac.Main has been deprecated.
> > C:\Programme\ImageJ\plugins\Template_Matching_.java:25: Package
> > Jama not found in import.
> > import Jama.*;
> >        ^
> > What can I do to use the package "Jama-1.0.2.jar".
> > I copied this jar-File to my imagej-directory and to the plugins-
> > directory.
Reply | Threaded
Open this post in threaded view
|

Re: problem with using external jar-files with the "compile and run" command

Joachim Walter
Hello all,

this looks like a bug in the current version of Jama(?) I use
Jama-1.0.1.jar calling it from a plugin without problems. I just have to
put it into the plugins-folder. No entry in the classpath necessary.
ImageJ seems to load the classes in the jar-file by itself.
This info is only for the compiled plugin, though. For compiling a
plugin, one might have to put Jama into the classpath. I use eclipse,
where I declare Jama as external jar-file.

Joachim



Robert Dougherty schrieb:

> In Windows, I think you are supposed to be able to add a .jar file to the
> class path in the Target line of a shortcut that runs ImageJ.  It didn't
> work for me; I still got "Package Jama not found in import."  Plan B was to
> download the source for the Jama package to the Plugins folder.  This
> produced an error I haven't seen before:
>
> error: Invalid class file format in C:\ImageJFST\plugins\Jama\Matrix.class.
> invalid constant type: 13
>
> What I finally stumbled through is given below.  It obviously should not be
> this difficult.  One thing that is probably still not right is that Matrix
> has a print method that writes to System.out, and this does not seem to be
> visible.
>
> 1. Download the source from http://math.nist.gov/javanumerics/jama/#Package
> 2. Expand and place the Jama folder in ImageJ\Plugins
> 3. Delete all the .class files in the top level of the Jama folder
> 4. Move Maths.java from Jama\util to Jama
> 5. Delete the Jama\util folder.
> 6. Edit Math.java and change "Package Jama.util;" to "Package Jama;"
> 7. Edit Matrix.java, EigenvalueDecomposition.java, QRDecomposition.java, and
> SingularValueDecomposition.java to remove "import Jama.util.*;"
> 8. Create a test plugin, such as Test_Jama.java, below.
> 9. Start ImageJ and "compile and run" the test plugin.
>    
> Test_Jama.java:
>
> import ij.*;
> import ij.plugin.PlugIn;
> import Jama.*;
>
> public class Test_Jama implements PlugIn{
>     public void run(String arg) {
> double[][] F = new double[3][3];
> for (int j = 0; j < 3; j++)
> for (int i = 0; i < 3; i++)
> F[i][j] = i+j;
> Matrix Fm = new Matrix(F);
> SingularValueDecomposition svd = Fm.svd();
> int rank = svd.rank();
> IJ.write("Rank = "+rank);
> }
> }
>
>
> Bob
>
>
>
> Robert P. Dougherty, Ph.D.
> President, OptiNav, Inc.
> Phone (425) 467-1118
> Fax (425) 467-1119
> www.optinav.com
>  
>  
>
>>On Mac OSX (like my system) that's usually in ~/Library/Java/
>>Extensions.  On a Windoze system it's in the lib\ext directory of
>>your Java installation.  If you are using the JRE that comes with
>>ImageJ, it's in the lib\ext directory of that installation.
>>
>>I use Jama in ImageJ plugins using the above locations without problem.
>>
>>Since you ARE on Windoze (from your post), if the above locations
>>can't be found, perhaps someone else on the list more familiar with
>>your operating system can chime in.
>>
>>
>>>
>>>When using the ImageJ "Compile and run..." command for my plugin, I
>>>get the following error:
>>>
>>>----------------------------------------------------------------------
>>>--
>>>Note: sun.tools.javac.Main has been deprecated.
>>>C:\Programme\ImageJ\plugins\Template_Matching_.java:25: Package
>>>Jama not found in import.
>>>import Jama.*;
>>>       ^
>>>What can I do to use the package "Jama-1.0.2.jar".
>>>I copied this jar-File to my imagej-directory and to the plugins-
>>>directory.


--
-----------------------------------------------
Dr. Joachim Walter

TILL I.D. GmbH
c\o BioImaging Zentrum
Großhaderner Str. 2
D-82152 Martinsried

Tel.: +49-89-2180-74189
Fax:  +49-89-2180-9974189

[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: problem with using external jar-files with the "compile and run" command

Marko Ulbrich
Hi all,

thanks for your fast help. This mailing list list is great!
The following hint made my plugins work correctly:

"If you are using the JRE that comes with ImageJ, it's in the lib\ext
directory of that installation."

I'm a windows user and so I copied Jama-1.0.2.jar to
C:\Programme\ImageJ\jre\lib\ext

Thanks for the other advices, too. Nice work ;)
Marko

> Hello all,
>
> this looks like a bug in the current version of Jama(?) I use
> Jama-1.0.1.jar calling it from a plugin without problems. I just have to
> put it into the plugins-folder. No entry in the classpath necessary.
> ImageJ seems to load the classes in the jar-file by itself.
> This info is only for the compiled plugin, though. For compiling a
> plugin, one might have to put Jama into the classpath. I use eclipse,
> where I declare Jama as external jar-file.
>
> Joachim
>
>
>
> Robert Dougherty schrieb:
>> In Windows, I think you are supposed to be able to add a .jar file to the
>> class path in the Target line of a shortcut that runs ImageJ.  It didn't
>> work for me; I still got "Package Jama not found in import."  Plan B
>> was to
>> download the source for the Jama package to the Plugins folder.  This
>> produced an error I haven't seen before:
>>
>> error: Invalid class file format in
>> C:\ImageJFST\plugins\Jama\Matrix.class.
>> invalid constant type: 13
>>
>> What I finally stumbled through is given below.  It obviously should
>> not be
>> this difficult.  One thing that is probably still not right is that
>> Matrix
>> has a print method that writes to System.out, and this does not seem
>> to be
>> visible.
>>
>> 1. Download the source from
>> http://math.nist.gov/javanumerics/jama/#Package
>> 2. Expand and place the Jama folder in ImageJ\Plugins
>> 3. Delete all the .class files in the top level of the Jama folder
>> 4. Move Maths.java from Jama\util to Jama
>> 5. Delete the Jama\util folder.
>> 6. Edit Math.java and change "Package Jama.util;" to "Package Jama;"
>> 7. Edit Matrix.java, EigenvalueDecomposition.java,
>> QRDecomposition.java, and
>> SingularValueDecomposition.java to remove "import Jama.util.*;"
>> 8. Create a test plugin, such as Test_Jama.java, below.
>> 9. Start ImageJ and "compile and run" the test plugin.
>>    Test_Jama.java:
>>
>> import ij.*;
>> import ij.plugin.PlugIn;
>> import Jama.*;
>>
>> public class Test_Jama implements PlugIn{
>>     public void run(String arg) {
>>         double[][] F = new double[3][3];
>>         for (int j = 0; j < 3; j++)
>>             for (int i = 0; i < 3; i++)
>>                 F[i][j] = i+j;
>>         Matrix Fm = new Matrix(F);
>>         SingularValueDecomposition svd = Fm.svd();
>>         int rank = svd.rank();
>>         IJ.write("Rank = "+rank);
>>     }
>> }
>>
>>
>> Bob
>>
>>
>>
>> Robert P. Dougherty, Ph.D.
>> President, OptiNav, Inc.
>> Phone (425) 467-1118
>> Fax (425) 467-1119
>> www.optinav.com
>>  
>>  
>>
>>> On Mac OSX (like my system) that's usually in ~/Library/Java/
>>> Extensions.  On a Windoze system it's in the lib\ext directory of
>>> your Java installation.  If you are using the JRE that comes with
>>> ImageJ, it's in the lib\ext directory of that installation.
>>>
>>> I use Jama in ImageJ plugins using the above locations without problem.
>>>
>>> Since you ARE on Windoze (from your post), if the above locations
>>> can't be found, perhaps someone else on the list more familiar with
>>> your operating system can chime in.
>>>
>>>
>>>>
>>>> When using the ImageJ "Compile and run..." command for my plugin, I
>>>> get the following error:
>>>>
>>>> ----------------------------------------------------------------------
>>>> --
>>>> Note: sun.tools.javac.Main has been deprecated.
>>>> C:\Programme\ImageJ\plugins\Template_Matching_.java:25: Package
>>>> Jama not found in import.
>>>> import Jama.*;
>>>>       ^
>>>> What can I do to use the package "Jama-1.0.2.jar".
>>>> I copied this jar-File to my imagej-directory and to the plugins-
>>>> directory.
>
>
Reply | Threaded
Open this post in threaded view
|

Re: problem with using external jar-files with the "compile and run" command

Robert Dougherty
> The following hint made my plugins work correctly:
>
> "If you are using the JRE that comes with ImageJ, it's in the lib\ext
> directory of that installation."
>
> I'm a windows user and so I copied Jama-1.0.2.jar to
> C:\Programme\ImageJ\jre\lib\ext
>

It works for me too.  It would have been easier to try Duane's suggestion
first.

> this looks like a bug in the current version of Jama(?) I use
> Jama-1.0.1.jar calling it from a plugin without problems.

For Jama-1.0.0 and Jama-1.0.1 it works to copy the source folder, with its
precompiled classes, to the ImageJ plugins folder.  The strange error
"invalid constant type: 13" seems to be new with Jama-1.0.2.  But the .jar
version, properly placed in the ImageJ\jre\lib\ext, does work.  So what
gives?  Comparing the .class files from the .jar and the .class files from
source folder (.zip), they do not match in size, so something may have gone
wrong in the Jama-1.0.2 release packaging.  The other problem I addressed in
my long installation seems to be an inability of ImageJ's compile and run
command to look down more than one level from the plugins folder.  This has
been discussed recently, but I have not been able to find it.

Bob
Reply | Threaded
Open this post in threaded view
|

Re: problem with using external jar-files with the "compile and run" command

Robert Dougherty
In reply to this post by Robert Dougherty
>One thing that is probably still not right is that Matrix
> has a print method that writes to System.out, and this does not seem to be
> visible.

There is a solution to this one in the archives:

https://list.nih.gov/cgi-bin/wa?A2=ind0412&L=IMAGEJ&P=R4061&I=-3

Bob
Reply | Threaded
Open this post in threaded view
|

Re: problem with using external jar-files with the "compile and run" command

Marko Ulbrich
Ok, I'll try it, thank you.


>> One thing that is probably still not right is that Matrix
>> has a print method that writes to System.out, and this does not seem to be
>> visible.
>
> There is a solution to this one in the archives:
>
> https://list.nih.gov/cgi-bin/wa?A2=ind0412&L=IMAGEJ&P=R4061&I=-3
>
> Bob
>