Import a java package in jython

imagej

#1

Hello everyone,

This is probably a stupid question, but since I don’t speak java I couldn’t figure it out so far.

I am trying to import a java package in my jython fiji script.
I downloaded the package (https://github.com/rmaestre/FastDTW) and placed it in a directory named FastDTW in my fiji plugins directory.

In a jython script I call
from com.dtw import FastDTW

It used to work for a while until at some point started giving me the error:
ImportError: No module named dtw

If I recall correctly Help>Refresh menus used to solve the problem.
Now it does not any more.

As far as I understand, I need to somehow register the java module but I don’t know how.

Could you please help me?

Thanks a lot…


#2

Hi @HarryR

please be more specific of what you downloaded and placed in your fiji plugins directory? Did you download

  • the source code of the package,
  • the compiled package, or
  • something else?

A list of the contents of /path/to/Fiji.app/plugins/FastDTW would be helpful

On a first glance I was not able to see any compiled packages following the link you shared. Java code is compiled before you can run it.


#3

Hi @hanslovsky,

I downloaded the source code:

C:\Local\fiji-win64\Fiji.app\plugins\FastDTW>tree
C:.
├───.idea
│ ├───artifacts
│ ├───copyright
│ ├───libraries
│ └───scopes
├───src
│ ├───main
│ │ ├───java
│ │ │ └───com
│ │ │ ├───dtw
│ │ │ ├───lang
│ │ │ ├───matrix
│ │ │ ├───timeseries
│ │ │ └───util
│ │ └───resources
│ └───test
│ └───java
└───target
├───classes
│ └───com
│ ├───dtw
│ ├───lang
│ ├───matrix
│ ├───timeseries
│ └───util
└───test-classes
└───test

This is now in my /path/to/Fiji.app/plugins/FastDTW directory.

When I delete the FastDTW, restart fiji, copy FastDTW again in the plugins directory, restart fiji and hit help>refresh menus it gets recognised again.

I think it has to do with the path environment variable. The Java package is not permanently introduced in the path variable, so fiji cannot find it when it is restarted.

Thanks


#4

Generally, the PATH variable specifies a set of directories where executable programs are located, so that should not affect the availability of your code. The classpath is the variable that is relevant here.
On Linux:

$ java -help
    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
                  A : separated list of directories, JAR archives,
                  and ZIP archives to search for class files.

That means that Java uses at all .class files within all directories or jar files specified on the classpath to resolve classes/methods. All you need to know now is what the ImageJ classpath is. You can open the script editor (File>New>Script...) and run this snippet

from java.lang import ClassLoader
cl = ClassLoader.getSystemClassLoader()
paths = map(lambda url: url.getFile(), cl.getURLs())
for path in paths:
    print path

To print all the entries on the classpath. For me, this looks like

/home/hanslovskyp/local/Fiji.app/jars/imagej-launcher-4.0.5.jar
/home/hanslovskyp/local/Fiji.app/jars/OMEVisual-1.1.1.jar
/home/hanslovskyp/local/Fiji.app/jars/jnr-x86asm-1.0.2.jar
/home/hanslovskyp/local/Fiji.app/jars/jcodings-1.0.10.jar
/home/hanslovskyp/local/Fiji.app/jars/batik-xml-1.9.1.jar
/home/hanslovskyp/local/Fiji.app/jars/batik-script-1.9.1.jar
/home/hanslovskyp/local/Fiji.app/jars/joal-2.3.2.jar
/home/hanslovskyp/local/Fiji.app/jars/VIB-lib-2.2.0.jar
/home/hanslovskyp/local/Fiji.app/jars/jep-2.4.2.jar
/home/hanslovskyp/local/Fiji.app/jars/trove4j-3.0.3.jar
/home/hanslovskyp/local/Fiji.app/jars/jfreechart-1.5.0.jar
/home/hanslovskyp/local/Fiji.app/jars/imglib2-algorithm-fft-0.1.5.jar
/home/hanslovskyp/local/Fiji.app/jars/op-finder-0.1.3.jar
/home/hanslovskyp/local/Fiji.app/jars/jackson-core-2.9.5.jar
/home/hanslovskyp/local/Fiji.app/jars/autocomplete-2.6.1.jar
/home/hanslovskyp/local/Fiji.app/jars/jsr305-3.0.1.jar
/home/hanslovskyp/local/Fiji.app/jars/jogl-all-main-2.3.2.jar
/home/hanslovskyp/local/Fiji.app/jars/itextpdf-5.5.12.jar
/home/hanslovskyp/local/Fiji.app/jars/args4j-2.33.jar
/home/hanslovskyp/local/Fiji.app/jars/scifio-bf-compat-2.0.3.jar
/home/hanslovskyp/local/Fiji.app/jars/fiji-lib-2.1.2.jar
/home/hanslovskyp/local/Fiji.app/jars/weave_jy2java-2.1.0.jar
/home/hanslovskyp/local/Fiji.app/jars/kryo-2.24.0.jar
/home/hanslovskyp/local/Fiji.app/jars/google-http-client-1.23.0.jar
/home/hanslovskyp/local/Fiji.app/jars/scripting-scala-0.2.1.jar
/home/hanslovskyp/local/Fiji.app/jars/gcc-runtime-0.8.1906.jar
/home/hanslovskyp/local/Fiji.app/jars/batik-gvt-1.9.1.jar
/home/hanslovskyp/local/Fiji.app/jars/trakem2-transform-1.0.0.jar
/home/hanslovskyp/local/Fiji.app/jars/imglib2-algorithm-gpl-0.2.2.jar
/home/hanslovskyp/local/Fiji.app/jars/scifio-jai-imageio-1.1.1.jar
/home/hanslovskyp/local/Fiji.app/jars/jackson-dataformat-cbor-2.6.7.jar
/home/hanslovskyp/local/Fiji.app/jars/methods-0.8.1906.jar
/home/hanslovskyp/local/Fiji.app/jars/google-cloud-core-1.20.0.jar
/home/hanslovskyp/local/Fiji.app/jars/ahocorasick-0.2.4.jar
/home/hanslovskyp/local/Fiji.app/jars/graphics-0.8.1906.jar
/home/hanslovskyp/local/Fiji.app/jars/scijava-config-2.0.2.jar
/home/hanslovskyp/local/Fiji.app/jars/mpicbg-1.1.1.jar
/home/hanslovskyp/local/Fiji.app/jars/gluegen-rt-main-2.3.2.jar
/home/hanslovskyp/local/Fiji.app/jars/renjin-appl-0.8.1906.jar
/home/hanslovskyp/local/Fiji.app/jars/jetty-6.1.26.jar
/home/hanslovskyp/local/Fiji.app/jars/scifio-lifesci-0.7.1.jar
/home/hanslovskyp/local/Fiji.app/jars/j3dcore-1.6.0-scijava-2.jar
/home/hanslovskyp/local/Fiji.app/jars/jgraphx-3.4.1.3.jar
/home/hanslovskyp/local/Fiji.app/jars/commons-logging-1.1.3.jar
/home/hanslovskyp/local/Fiji.app/jars/renjin-core-0.8.1906.jar
/home/hanslovskyp/local/Fiji.app/jars/google-api-services-oauth2-v2-rev134-1.23.0.jar
/home/hanslovskyp/local/Fiji.app/jars/google-http-client-jackson2-1.23.0.jar
/home/hanslovskyp/local/Fiji.app/jars/image4j-0.7.jar
/home/hanslovskyp/local/Fiji.app/jars/threetenbp-1.3.3.jar
/home/hanslovskyp/local/Fiji.app/jars/log4j-1.2.17.jar
/home/hanslovskyp/local/Fiji.app/jars/httpclient-4.5.5.jar
/home/hanslovskyp/local/Fiji.app/jars/udunits-4.3.18.jar
/home/hanslovskyp/local/Fiji.app/jars/jhotdraw-7.6.0.jar
/home/hanslovskyp/local/Fiji.app/jars/imagej-ops-0.39.0.jar
/home/hanslovskyp/local/Fiji.app/jars/protobuf-java-util-3.5.1.jar
/home/hanslovskyp/local/Fiji.app/jars/regexp-1.3.jar
/home/hanslovskyp/local/Fiji.app/jars/f2jutil-0.8.jar
/home/hanslovskyp/local/Fiji.app/jars/protobuf-java-3.5.1.jar
/home/hanslovskyp/local/Fiji.app/jars/scifio-cli-0.3.4.jar
/home/hanslovskyp/local/Fiji.app/jars/scripting-jython-0.4.1.jar
/home/hanslovskyp/local/Fiji.app/jars/error_prone_annotations-2.2.0.jar
/home/hanslovskyp/local/Fiji.app/jars/google-cloud-resourcemanager-0.38.0-alpha.jar
/home/hanslovskyp/local/Fiji.app/jars/batik-constants-1.9.1.jar
/home/hanslovskyp/local/Fiji.app/jars/blas-0.8.jar
/home/hanslovskyp/local/Fiji.app/jars/jruby-core-1.7.12.jar
/home/hanslovskyp/local/Fiji.app/jars/aws-java-sdk-core-1.11.294.jar
/home/hanslovskyp/local/Fiji.app/jars/asm-analysis-4.0.jar
/home/hanslovskyp/local/Fiji.app/jars/jnr-enxio-0.4.jar
/home/hanslovskyp/local/Fiji.app/jars/ome-common-5.3.4.jar
/home/hanslovskyp/local/Fiji.app/jars/commons-lang-2.4.jar
/home/hanslovskyp/local/Fiji.app/jars/eventbus-1.4.jar
/home/hanslovskyp/local/Fiji.app/jars/scala-xml_2.12-1.0.6.jar
/home/hanslovskyp/local/Fiji.app/jars/imagej-ui-swing-0.21.3.jar
/home/hanslovskyp/local/Fiji.app/jars/jdom2-2.0.6.jar
/home/hanslovskyp/local/Fiji.app/jars/nailgun-server-0.9.1.jar
/home/hanslovskyp/local/Fiji.app/jars/batik-css-1.9.1.jar
/home/hanslovskyp/local/Fiji.app/jars/imagej-plugins-tools-0.3.1.jar
/home/hanslovskyp/local/Fiji.app/jars/scijava-plugins-text-plain-0.1.3.jar
/home/hanslovskyp/local/Fiji.app/jars/jnr-ffi-1.0.7.jar
/home/hanslovskyp/local/Fiji.app/jars/scala-compiler-2.12.1.jar
/home/hanslovskyp/local/Fiji.app/jars/javacpp-0.11.jar
/home/hanslovskyp/local/Fiji.app/jars/httpcore-4.4.9.jar
/home/hanslovskyp/local/Fiji.app/jars/plexus-utils-1.5.6.jar
/home/hanslovskyp/local/Fiji.app/jars/filters-2.0.235.jar
/home/hanslovskyp/local/Fiji.app/jars/scijava-common-2.69.0.jar
/home/hanslovskyp/local/Fiji.app/jars/asm-util-4.0.jar
/home/hanslovskyp/local/Fiji.app/jars/scripting-groovy-0.2.6.jar
/home/hanslovskyp/local/Fiji.app/jars/jpedalSTD-2.80b11.jar
/home/hanslovskyp/local/Fiji.app/jars/google-api-client-1.23.0.jar
/home/hanslovskyp/local/Fiji.app/jars/batik-ext-1.9.1.jar
/home/hanslovskyp/local/Fiji.app/jars/scijava-plugins-commands-0.2.3.jar
/home/hanslovskyp/local/Fiji.app/jars/xmpcore-5.1.2.jar
/home/hanslovskyp/local/Fiji.app/jars/jitk-tps-3.0.0.jar
/home/hanslovskyp/local/Fiji.app/jars/jackson-annotations-2.9.0.jar
/home/hanslovskyp/local/Fiji.app/jars/aws-java-sdk-kms-1.11.294.jar
/home/hanslovskyp/local/Fiji.app/jars/n5-google-cloud-2.0.2.jar
/home/hanslovskyp/local/Fiji.app/jars/jocl-2.3.2.jar
/home/hanslovskyp/local/Fiji.app/jars/scijava-plugins-platforms-0.3.1.jar
/home/hanslovskyp/local/Fiji.app/jars/scripting-jruby-0.2.5.jar
/home/hanslovskyp/local/Fiji.app/jars/batik-i18n-1.9.1.jar
/home/hanslovskyp/local/Fiji.app/jars/scripting-clojure-0.1.6.jar
/home/hanslovskyp/local/Fiji.app/jars/aws-java-sdk-s3-1.11.294.jar
/home/hanslovskyp/local/Fiji.app/jars/minlog-1.2.jar
/home/hanslovskyp/local/Fiji.app/jars/specification-5.5.4.jar
/home/hanslovskyp/local/Fiji.app/jars/bounce-0.18.jar
/home/hanslovskyp/local/Fiji.app/jars/gax-1.19.0.jar
/home/hanslovskyp/local/Fiji.app/jars/maven-scm-api-1.4.jar
/home/hanslovskyp/local/Fiji.app/jars/imagej-plugins-uploader-webdav-0.2.2.jar
/home/hanslovskyp/local/Fiji.app/jars/commons-math-2.2.jar
/home/hanslovskyp/local/Fiji.app/jars/markdownj-0.3.0-1.0.2b4.jar
/home/hanslovskyp/local/Fiji.app/jars/jogl-all-2.3.2.jar
/home/hanslovskyp/local/Fiji.app/jars/maven-scm-provider-svnexe-1.4.jar
/home/hanslovskyp/local/Fiji.app/jars/scripting-javascript-0.4.4.jar
/home/hanslovskyp/local/Fiji.app/jars/groovy-2.4.8.jar
/home/hanslovskyp/local/Fiji.app/jars/spim_data-2.2.1.jar
/home/hanslovskyp/local/Fiji.app/jars/google-api-services-storage-v1-rev114-1.23.0.jar
/home/hanslovskyp/local/Fiji.app/jars/scijava-ui-awt-0.1.6.jar
/home/hanslovskyp/local/Fiji.app/jars/asm-tree-4.0.jar
/home/hanslovskyp/local/Fiji.app/jars/ome-xml-5.6.2.jar
/home/hanslovskyp/local/Fiji.app/jars/lz4-1.3.0.jar
/home/hanslovskyp/local/Fiji.app/jars/batik-svggen-1.9.1.jar
/home/hanslovskyp/local/Fiji.app/jars/mtj-1.0.4.jar
/home/hanslovskyp/local/Fiji.app/jars/commons-vfs2-2.0.jar
/home/hanslovskyp/local/Fiji.app/jars/fiji-2.0.0-pre-4.jar
/home/hanslovskyp/local/Fiji.app/jars/google-api-services-cloudresourcemanager-v1-rev470-1.23.0.jar
/home/hanslovskyp/local/Fiji.app/jars/jnr-posix-3.0.1.jar
/home/hanslovskyp/local/Fiji.app/jars/imagej-plugins-uploader-ssh-0.3.2.jar
/home/hanslovskyp/local/Fiji.app/jars/bigdataviewer_fiji-4.0.2.jar
/home/hanslovskyp/local/Fiji.app/jars/commons-beanutils-1.9.3.jar
/home/hanslovskyp/local/Fiji.app/jars/swingx-1.6.1.jar
/home/hanslovskyp/local/Fiji.app/jars/bigdataviewer-core-4.3.1.jar
/home/hanslovskyp/local/Fiji.app/jars/jna-4.5.0.jar
/home/hanslovskyp/local/Fiji.app/jars/jgoodies-common-1.7.0.jar
/home/hanslovskyp/local/Fiji.app/jars/ome-poi-5.3.1.jar
/home/hanslovskyp/local/Fiji.app/jars/batik-parser-1.9.1.jar
/home/hanslovskyp/local/Fiji.app/jars/servlet-api-2.5-20081211.jar
/home/hanslovskyp/local/Fiji.app/jars/jzlib-1.1.3.jar
/home/hanslovskyp/local/Fiji.app/jars/jackson-databind-2.9.5.jar
/home/hanslovskyp/local/Fiji.app/jars/imglib2-realtransform-2.0.0-beta-38.jar
/home/hanslovskyp/local/Fiji.app/jars/ui-behaviour-1.3.0.jar
/home/hanslovskyp/local/Fiji.app/jars/n5-aws-s3-2.0.2.jar
/home/hanslovskyp/local/Fiji.app/jars/imglib2-roi-0.4.7.jar
/home/hanslovskyp/local/Fiji.app/jars/jruby-stdlib-1.7.12.jar
/home/hanslovskyp/local/Fiji.app/jars/xml-apis-ext-1.3.04.jar
/home/hanslovskyp/local/Fiji.app/jars/jetty-util-6.1.26.jar
/home/hanslovskyp/local/Fiji.app/jars/scripting-renjin-0.2.2.jar
/home/hanslovskyp/local/Fiji.app/jars/gax-httpjson-0.36.0.jar
/home/hanslovskyp/local/Fiji.app/jars/opencsv-3.9.jar
/home/hanslovskyp/local/Fiji.app/jars/imglib2-cache-1.0.0-beta-7.jar
/home/hanslovskyp/local/Fiji.app/jars/api-common-1.4.0.jar
/home/hanslovskyp/local/Fiji.app/jars/legacy-imglib1-1.1.8.jar
/home/hanslovskyp/local/Fiji.app/jars/imglib2-ij-2.0.0-beta-39.jar
/home/hanslovskyp/local/Fiji.app/jars/n5-2.0.2.jar
/home/hanslovskyp/local/Fiji.app/jars/vecmath-1.6.0-scijava-2.jar
/home/hanslovskyp/local/Fiji.app/jars/jai-core-1.1.3.jar
/home/hanslovskyp/local/Fiji.app/jars/scijava-plugins-text-markdown-0.1.3.jar
/home/hanslovskyp/local/Fiji.app/jars/proto-google-iam-v1-0.3.0.jar
/home/hanslovskyp/local/Fiji.app/jars/xz-1.6.jar
/home/hanslovskyp/local/Fiji.app/jars/scifio-hdf5-0.1.2.jar
/home/hanslovskyp/local/Fiji.app/jars/j3dutils-1.6.0-scijava-2.jar
/home/hanslovskyp/local/Fiji.app/jars/T2-NIT-1.1.2.jar
/home/hanslovskyp/local/Fiji.app/jars/metadata-extractor-2.6.2.jar
/home/hanslovskyp/local/Fiji.app/jars/joal-main-2.3.2.jar
/home/hanslovskyp/local/Fiji.app/jars/options-1.1.jar
/home/hanslovskyp/local/Fiji.app/jars/jmespath-java-1.11.294.jar
/home/hanslovskyp/local/Fiji.app/jars/imagej-2.0.0-rc-65.jar
/home/hanslovskyp/local/Fiji.app/jars/commons-codec-1.11.jar
/home/hanslovskyp/local/Fiji.app/jars/gson-2.8.2.jar
/home/hanslovskyp/local/Fiji.app/jars/VectorString-2.0.1.jar
/home/hanslovskyp/local/Fiji.app/jars/jai-codec-1.1.3.jar
/home/hanslovskyp/local/Fiji.app/jars/jhdf5-14.12.6.jar
/home/hanslovskyp/local/Fiji.app/jars/ejml-0.24.jar
/home/hanslovskyp/local/Fiji.app/jars/perf4j-0.9.13.jar
/home/hanslovskyp/local/Fiji.app/jars/batik-util-1.9.1.jar
/home/hanslovskyp/local/Fiji.app/jars/postgresql-9.1-901-1.jdbc4.jar
/home/hanslovskyp/local/Fiji.app/jars/jgrapht-0.8.3.jar
/home/hanslovskyp/local/Fiji.app/jars/bsh-2.0b6.jar
/home/hanslovskyp/local/Fiji.app/jars/bytelist-1.0.11.jar
/home/hanslovskyp/local/Fiji.app/jars/jffi-1.2.7-native.jar
/home/hanslovskyp/local/Fiji.app/jars/commons-compress-1.14.jar
/home/hanslovskyp/local/Fiji.app/jars/linux64/ffmpeg-2.6.1-0.11-linux-x86_64.jar
/home/hanslovskyp/local/Fiji.app/jars/linux64/gluegen-rt-2.3.2-natives-linux-amd64.jar
/home/hanslovskyp/local/Fiji.app/jars/linux64/joal-2.3.2-natives-linux-amd64.jar
/home/hanslovskyp/local/Fiji.app/jars/linux64/jocl-2.3.2-natives-linux-amd64.jar
/home/hanslovskyp/local/Fiji.app/jars/linux64/jogl-all-2.3.2-natives-linux-amd64.jar
/home/hanslovskyp/local/Fiji.app/jars/jama-1.0.3.jar
/home/hanslovskyp/local/Fiji.app/jars/jcommander-1.48.jar
/home/hanslovskyp/local/Fiji.app/jars/renjin-gnur-runtime-0.8.1906.jar
/home/hanslovskyp/local/Fiji.app/jars/utils-0.8.1906.jar
/home/hanslovskyp/local/Fiji.app/jars/joni-2.1.1.jar
/home/hanslovskyp/local/Fiji.app/jars/google-auth-library-oauth2-http-0.9.0.jar
/home/hanslovskyp/local/Fiji.app/jars/asm-4.0.jar
/home/hanslovskyp/local/Fiji.app/jars/slf4j-api-1.7.25.jar
/home/hanslovskyp/local/Fiji.app/jars/grDevices-0.8.1906.jar
/home/hanslovskyp/local/Fiji.app/jars/ivy-2.2.0.jar
/home/hanslovskyp/local/Fiji.app/jars/caffeine-2.4.0.jar
/home/hanslovskyp/local/Fiji.app/jars/opencensus-contrib-http-util-0.11.1.jar
/home/hanslovskyp/local/Fiji.app/jars/ome-jai-0.1.0.jar
/home/hanslovskyp/local/Fiji.app/jars/datasets-0.8.1906.jar
/home/hanslovskyp/local/Fiji.app/jars/mapdb-1.0.3.jar
/home/hanslovskyp/local/Fiji.app/jars/clojure-1.8.0.jar
/home/hanslovskyp/local/Fiji.app/jars/jgoodies-forms-1.7.2.jar
/home/hanslovskyp/local/Fiji.app/jars/snakeyaml-1.13.jar
/home/hanslovskyp/local/Fiji.app/jars/xerbla-0.8.jar
/home/hanslovskyp/local/Fiji.app/jars/jtransforms-2.4.jar
/home/hanslovskyp/local/Fiji.app/jars/codemodel-2.6.jar
/home/hanslovskyp/local/Fiji.app/jars/batik-bridge-1.9.1.jar
/home/hanslovskyp/local/Fiji.app/jars/n5-imglib2-2.1.1.jar
/home/hanslovskyp/local/Fiji.app/jars/google-oauth-client-jetty-1.23.0.jar
/home/hanslovskyp/local/Fiji.app/jars/batik-codec-1.9.jar
/home/hanslovskyp/local/Fiji.app/jars/pal-optimization-2.0.1.jar
/home/hanslovskyp/local/Fiji.app/jars/scala-reflect-2.12.1.jar
/home/hanslovskyp/local/Fiji.app/jars/ojalgo-43.0.jar
/home/hanslovskyp/local/Fiji.app/jars/imagej-notebook-0.2.3.jar
/home/hanslovskyp/local/Fiji.app/jars/xercesImpl-2.8.1.jar
/home/hanslovskyp/local/Fiji.app/jars/scripting-beanshell-0.3.3.jar
/home/hanslovskyp/local/Fiji.app/jars/miglayout-3.7.4-swing.jar
/home/hanslovskyp/local/Fiji.app/jars/commons-collections-3.2.2.jar
/home/hanslovskyp/local/Fiji.app/jars/fiji-compat-2.0.3.jar
/home/hanslovskyp/local/Fiji.app/jars/jackson-core-asl-1.9.11.jar
/home/hanslovskyp/local/Fiji.app/jars/jdatepicker-1.3.2.jar
/home/hanslovskyp/local/Fiji.app/jars/ij-1.51s.jar
/home/hanslovskyp/local/Fiji.app/jars/scijava-ui-swing-0.9.5.jar
/home/hanslovskyp/local/Fiji.app/jars/ome-codecs-0.2.0.jar
/home/hanslovskyp/local/Fiji.app/jars/joda-time-2.9.9.jar
/home/hanslovskyp/local/Fiji.app/jars/xmlgraphics-commons-2.2.jar
/home/hanslovskyp/local/Fiji.app/jars/google-http-client-jackson-1.23.0.jar
/home/hanslovskyp/local/Fiji.app/jars/batik-dom-1.9.1.jar
/home/hanslovskyp/local/Fiji.app/jars/ome-mdbtools-5.3.0.jar
/home/hanslovskyp/local/Fiji.app/jars/batik-transcoder-1.9.jar
/home/hanslovskyp/local/Fiji.app/jars/bigdataviewer-vistools-1.0.0-beta-8.jar
/home/hanslovskyp/local/Fiji.app/jars/imagej-ui-awt-0.3.1.jar
/home/hanslovskyp/local/Fiji.app/jars/logback-core-1.2.3.jar
/home/hanslovskyp/local/Fiji.app/jars/jsch-0.1.54.jar
/home/hanslovskyp/local/Fiji.app/jars/lapack-0.8.jar
/home/hanslovskyp/local/Fiji.app/jars/imagej-updater-0.8.3.jar
/home/hanslovskyp/local/Fiji.app/jars/jython-shaded-2.7.0.jar
/home/hanslovskyp/local/Fiji.app/jars/google-http-client-appengine-1.23.0.jar
/home/hanslovskyp/local/Fiji.app/jars/maven-scm-provider-svn-commons-1.4.jar
/home/hanslovskyp/local/Fiji.app/jars/commons-math3-3.6.1.jar
/home/hanslovskyp/local/Fiji.app/jars/imglib2-algorithm-0.8.2.jar
/home/hanslovskyp/local/Fiji.app/jars/netcdf-4.3.22.jar
/home/hanslovskyp/local/Fiji.app/jars/scijava-search-0.4.0.jar
/home/hanslovskyp/local/Fiji.app/jars/jung-api-2.0.1.jar
/home/hanslovskyp/local/Fiji.app/jars/collections-generic-4.01.jar
/home/hanslovskyp/local/Fiji.app/jars/commons-lang3-3.7.jar
/home/hanslovskyp/local/Fiji.app/jars/invokebinder-1.2.jar
/home/hanslovskyp/local/Fiji.app/jars/guava-21.0.jar
/home/hanslovskyp/local/Fiji.app/jars/gluegen-rt-2.3.2.jar
/home/hanslovskyp/local/Fiji.app/jars/metakit-5.3.0.jar
/home/hanslovskyp/local/Fiji.app/jars/jffi-1.2.7.jar
/home/hanslovskyp/local/Fiji.app/jars/imagej-plugins-commands-0.7.1.jar
/home/hanslovskyp/local/Fiji.app/jars/mines-jtk-20151125.jar
/home/hanslovskyp/local/Fiji.app/jars/jnr-unixsocket-0.3.jar
/home/hanslovskyp/local/Fiji.app/jars/scripting-java-0.4.1.jar
/home/hanslovskyp/local/Fiji.app/jars/ij1-patcher-0.12.8.jar
/home/hanslovskyp/local/Fiji.app/jars/jocl-main-2.3.2.jar
/home/hanslovskyp/local/Fiji.app/jars/opencensus-api-0.11.1.jar
/home/hanslovskyp/local/Fiji.app/jars/ffmpeg-2.6.1-0.11.jar
/home/hanslovskyp/local/Fiji.app/jars/imagej-legacy-0.29.0.jar
/home/hanslovskyp/local/Fiji.app/jars/bio-formats/formats-bsd-5.7.3.jar
/home/hanslovskyp/local/Fiji.app/jars/bio-formats/formats-gpl-5.7.3.jar
/home/hanslovskyp/local/Fiji.app/jars/bio-formats/turbojpeg-5.7.3.jar
/home/hanslovskyp/local/Fiji.app/jars/bio-formats/ome-common-5.3.4.jar
/home/hanslovskyp/local/Fiji.app/jars/bio-formats/specification-5.5.4.jar
/home/hanslovskyp/local/Fiji.app/jars/bio-formats/ome-xml-5.6.2.jar
/home/hanslovskyp/local/Fiji.app/jars/bio-formats/ome-poi-5.3.1.jar
/home/hanslovskyp/local/Fiji.app/jars/bio-formats/jai_imageio-5.5.3.jar
/home/hanslovskyp/local/Fiji.app/jars/bio-formats/ome-jai-0.1.0.jar
/home/hanslovskyp/local/Fiji.app/jars/bio-formats/ome-codecs-0.2.0.jar
/home/hanslovskyp/local/Fiji.app/jars/bio-formats/ome-mdbtools-5.3.0.jar
/home/hanslovskyp/local/Fiji.app/jars/bio-formats/metakit-5.3.0.jar
/home/hanslovskyp/local/Fiji.app/jars/bio-formats/jxrlib-all-0.2.1.jar
/home/hanslovskyp/local/Fiji.app/jars/bio-formats/formats-api-5.7.3.jar
/home/hanslovskyp/local/Fiji.app/jars/scifio-ome-xml-0.14.3.jar
/home/hanslovskyp/local/Fiji.app/jars/google-oauth-client-1.23.0.jar
/home/hanslovskyp/local/Fiji.app/jars/imglib2-4.6.1.jar
/home/hanslovskyp/local/Fiji.app/jars/jcommon-1.0.24.jar
/home/hanslovskyp/local/Fiji.app/jars/weka-dev-3.9.2.jar
/home/hanslovskyp/local/Fiji.app/jars/JWlz-1.4.0.jar
/home/hanslovskyp/local/Fiji.app/jars/yecht-1.0.jar
/home/hanslovskyp/local/Fiji.app/jars/batik-svg-dom-1.9.1.jar
/home/hanslovskyp/local/Fiji.app/jars/jnr-constants-0.8.5.jar
/home/hanslovskyp/local/Fiji.app/jars/ion-java-1.0.2.jar
/home/hanslovskyp/local/Fiji.app/jars/imglib2-ui-2.0.0-beta-33.jar
/home/hanslovskyp/local/Fiji.app/jars/jsoup-1.7.2.jar
/home/hanslovskyp/local/Fiji.app/jars/object-inspector-0.1.jar
/home/hanslovskyp/local/Fiji.app/jars/swing-checkbox-tree-1.0.2.jar
/home/hanslovskyp/local/Fiji.app/jars/jung-graph-impl-2.0.1.jar
/home/hanslovskyp/local/Fiji.app/jars/T2-TreelineGraph-1.1.2.jar
/home/hanslovskyp/local/Fiji.app/jars/commons-io-2.6.jar
/home/hanslovskyp/local/Fiji.app/jars/script-editor-0.1.5.jar
/home/hanslovskyp/local/Fiji.app/jars/languagesupport-2.6.0.jar
/home/hanslovskyp/local/Fiji.app/jars/imagej-common-0.24.9.jar
/home/hanslovskyp/local/Fiji.app/jars/google-cloud-storage-1.20.0.jar
/home/hanslovskyp/local/Fiji.app/jars/gentyref-1.1.0.jar
/home/hanslovskyp/local/Fiji.app/jars/objenesis-2.1.jar
/home/hanslovskyp/local/Fiji.app/jars/grpc-context-1.9.0.jar
/home/hanslovskyp/local/Fiji.app/jars/logback-classic-1.2.3.jar
/home/hanslovskyp/local/Fiji.app/jars/scifio-0.33.0.jar
/home/hanslovskyp/local/Fiji.app/jars/jnr-netdb-1.1.2.jar
/home/hanslovskyp/local/Fiji.app/jars/imagej-deprecated-0.1.2.jar
/home/hanslovskyp/local/Fiji.app/jars/rhino-1.7.6.jar
/home/hanslovskyp/local/Fiji.app/jars/minimaven-2.2.1.jar
/home/hanslovskyp/local/Fiji.app/jars/batik-awt-util-1.9.1.jar
/home/hanslovskyp/local/Fiji.app/jars/asm-commons-4.0.jar
/home/hanslovskyp/local/Fiji.app/jars/rsyntaxtextarea-2.6.1.jar
/home/hanslovskyp/local/Fiji.app/jars/parsington-1.0.1.jar
/home/hanslovskyp/local/Fiji.app/jars/stats-0.8.1906.jar
/home/hanslovskyp/local/Fiji.app/jars/scala-library-2.12.1.jar
/home/hanslovskyp/local/Fiji.app/jars/base64-2.3.8.jar
/home/hanslovskyp/local/Fiji.app/jars/swing-worker-1.1.jar
/home/hanslovskyp/local/Fiji.app/jars/renjin-script-engine-0.8.1906.jar
/home/hanslovskyp/local/Fiji.app/jars/imagej-scripting-0.7.0.jar
/home/hanslovskyp/local/Fiji.app/jars/netlib-java-0.9.3-renjin-patched-2.jar
/home/hanslovskyp/local/Fiji.app/jars/javassist-3.22.0-GA.jar
/home/hanslovskyp/local/Fiji.app/jars/google-auth-library-credentials-0.9.0.jar
/home/hanslovskyp/local/Fiji.app/jars/proto-google-common-protos-1.2.0.jar
/home/hanslovskyp/local/Fiji.app/jars/native-lib-loader-2.2.0.jar
/home/hanslovskyp/local/Fiji.app/jars/google-oauth-client-java6-1.23.0.jar
/home/hanslovskyp/local/Fiji.app/jars/google-cloud-core-http-1.20.0.jar
/home/hanslovskyp/local/Fiji.app/jars/batik-anim-1.9.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/Fiji_Package_Maker-2.1.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/Descriptor_based_registration-2.1.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/TrakEM2_-1.0i.jar
/home/hanslovskyp/local/Fiji.app/plugins/Stitching_-3.1.5.jar
/home/hanslovskyp/local/Fiji.app/plugins/Fiji_Archipelago-2.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/TrackMate_-3.6.0.jar
/home/hanslovskyp/local/Fiji.app/plugins/Skeletonize3D_-2.1.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/bigwarp_fiji-3.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/3D_Blob_Segmentation-3.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/n5-viewer_fiji-2.0.1-SNAPSHOT.jar
/home/hanslovskyp/local/Fiji.app/plugins/Stack_Manipulation-2.1.0.jar
/home/hanslovskyp/local/Fiji.app/plugins/Fiji_Developer-2.0.6.jar
/home/hanslovskyp/local/Fiji.app/plugins/registration_3d-2.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/FlowJ_-1.29.3.jar
/home/hanslovskyp/local/Fiji.app/plugins/Statistical_Region_Merging-2.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/Interactive_3D_Surface_Plot-3.0.0.jar
/home/hanslovskyp/local/Fiji.app/plugins/Colocalisation_Analysis-3.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/Anisotropic_Diffusion_2D-2.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/trakem2_tps-1.1.3.jar
/home/hanslovskyp/local/Fiji.app/plugins/TopoJ_-2.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/Multi_Kymograph-3.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/Dichromacy_-2.1.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/Volume_Viewer-2.01.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/3D_Viewer-4.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/KymographBuilder-2.0.0.jar
/home/hanslovskyp/local/Fiji.app/plugins/FS_Align_TrakEM2-2.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/Archipelago_Plugins-0.5.4.jar
/home/hanslovskyp/local/Fiji.app/plugins/Auto_Threshold-1.17.0.jar
/home/hanslovskyp/local/Fiji.app/plugins/Fiji_Plugins-3.1.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/Feature_Detection-2.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/Color_Inspector_3D-2.3.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/CPU_Meter-2.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/Directionality_-2.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/z_spacing-1.0.3.jar
/home/hanslovskyp/local/Fiji.app/plugins/Time_Stamper-2.1.0.jar
/home/hanslovskyp/local/Fiji.app/plugins/bigdataviewer_fiji-4.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/Arrow_-2.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/mpicbg_-1.1.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/Image_Synthesizer.jar
/home/hanslovskyp/local/Fiji.app/plugins/LSM_Reader-4.1.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/Bug_Submitter-2.1.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/Thread_Killer-2.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/Sync_Win-1.7-fiji4.jar
/home/hanslovskyp/local/Fiji.app/plugins/Series_Labeler-2.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/Manual_Tracking-2.1.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/LocalThickness_-4.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/Reconstruct_Reader-2.0.3.jar
/home/hanslovskyp/local/Fiji.app/plugins/M_I_P-2.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/3D_Objects_Counter-2.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/Image_5D-2.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/Lasso_and_Blow_Tool-2.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/Sholl_Analysis-3.7.0.jar
/home/hanslovskyp/local/Fiji.app/plugins/bUnwarpJ_-2.6.9.jar
/home/hanslovskyp/local/Fiji.app/plugins/Siox_Segmentation-1.0.5.jar
/home/hanslovskyp/local/Fiji.app/plugins/QuickPALM_-1.1.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/bio-formats_plugins-5.7.3.jar
/home/hanslovskyp/local/Fiji.app/plugins/Samples_-2.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/PIV_analyser-1.1.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/Calculator_Plus-2.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/CorrectBleach_-2.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/panorama_-3.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/blockmatching_-2.1.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/AnalyzeSkeleton_-3.2.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/ToAST_-25.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/Kuwahara_Filter-2.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/RATS_-2.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/Colour_Deconvolution-3.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/Correct_3D_Drift-1.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/Helmholtz_Analysis-2.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/IJ_Robot-2.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/IO_-3.0.4.jar
/home/hanslovskyp/local/Fiji.app/plugins/Color_Histogram-2.0.7.jar
/home/hanslovskyp/local/Fiji.app/plugins/Trainable_Segmentation-3.2.21.jar
/home/hanslovskyp/local/Fiji.app/plugins/H5J_Loader_Plugin-1.0.6.jar
/home/hanslovskyp/local/Fiji.app/plugins/Linear_Kuwahara-2.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/level_sets-1.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/MTrack2_-2.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/VIB_-3.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/register_virtual_stack_slices-3.0.4.jar
/home/hanslovskyp/local/Fiji.app/plugins/Simple_Neurite_Tracer-3.1.5.jar
/home/hanslovskyp/local/Fiji.app/plugins/Vaa3d_Writer-1.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/Image_Expression_Parser-3.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/Gray_Morphology-2.3.4.jar
/home/hanslovskyp/local/Fiji.app/plugins/View5D_-1.3.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/SPIM_Opener-2.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/Graph_Cut-1.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/IsoData_Classifier-2.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/Time_Lapse-2.1.0.jar
/home/hanslovskyp/local/Fiji.app/plugins/TrakEM2_Archipelago-2.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/LSM_Toolbox-4.1.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/SplineDeformationGenerator_-2.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/BalloonSegmentation_-3.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/Video_Editing-2.0.1.jar
/home/hanslovskyp/local/Fiji.app/plugins/Cell_Counter-2.2.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/SPIM_Registration-5.0.18.jar
/home/hanslovskyp/local/Fiji.app/plugins/Volume_Calculator-2.0.2.jar
/home/hanslovskyp/local/Fiji.app/plugins/Vaa3d_Reader-2.0.2.jar

What you will notice is that all jar files are either located in the plugins directory or the jars directory, not in any of the subdirectories. What you need to do is to copy the jar file you compiled into the plugins or the jars directory (ImageJ/Fiji experts might chime in on that). Assuming that FastDTW is not an actual plugin but a jar with code that you depend on, I recommend you copy it to the jars directory. For me, this would look like:

/home/hanslovskyp/local/Fiji.app/jars/FastDTW-1.0-SNAPSHOT.jar

Further reading:


#5

Hello hanslovsky,

Thank you for your help and sorry for the late reply, I have been pretty busy lately.

FastDTW is not a FiJi plugin. It’s just some java code I downloaded.
I am calling classes and operations from it in my jython script.

As I am not familiar with Java, I don’t know how to compile the code, nor how to call a .jar through a jython script.

There is no .jar file the code I downloaded.

What I want is to actually call the classes just as I do.

Any comments on this?

Cheers.


#6

Java code needs to be built into .class files (and optionally be packaged into .jar files) before you can call it from another plugin or script. In Fiji, this doesn’t happen automatically (you need to have a JDK installation and not just the bundled JRE).

To make your life easier, you can use this enhanced version of FastDTW:

It has been built and deployed using Maven, and a jar file is available from here:

http://maven.imagej.net/service/local/repositories/sonatype/content/com/github/davidmoten/fastdtw/0.1/fastdtw-0.1.jar

@HarryR If you put this jar file into your ./Fiji.app/jars (and remove your previous FastDTW folder), you should be able to call the classes from Jython just fine.