Hallo Welt für ImageJ Java Plugin

I wrote a few ImageJ plugins a decade ago, and at that time it was relatively simple. ImageJ only worked with Java or ImageJ Macro language. But ImageJ is like a hybrid of ImageJ1 and ImageJ2, which are completely different internally, and it accepts scripting in BeanShell, Groovy, ImageJ Macro, JavaScript, Lisp (Clojure), MATLAB, Python, R, Ruby, and Scala, half of which I've never heard of.

With that, the way to write and execute the simplest ImageJ Plugin in Java was kind of lost, at least to me. It certainly doesn't exist in the Scripting page.Maybethis is the page, but it's rather difficult to reach and doesn't seem to give you the simplest code example.

I've written an article about "Hello world" for ImageJ with Eclipse", but this is way too complicated for a beginner and me.

So, here I show you how to write the simplest "Hello World" ImageJ Plugin.

  1. Save the Java source code (.java)

1. File > New > Script... will open a new script document in the Script Editor. Image005.png

2. In the Script Editor, select Templates > [by Language] > Java > Imagej 1.x > Skeltons > Bare Plugin. Image006.png

3. You'll see this code. Image007.png

4. Copy and paste the following code to the file.

import ij.plugin.PlugIn;
import ij.IJ;

/**
 * This is a template for a plugin that does not require one image
 * (be it that it does not require any, or that it lets the user
 * choose more than one image in a dialog).
 */
public class Bare_PlugIn implements PlugIn {
	/**
	 * This method gets called by ImageJ / Fiji.
	 *
	 * @param arg can be specified in plugins.config
	 * @see ij.plugin.PlugIn#run(java.lang.String)
	 */
	@Override
	public void run(String arg) {
		IJ.showMessage("Hello World");
	}
}
import ij.IJ;
IJ.showMessage("Hello World");

5. After the edit, it should look like this. Image009.png

6. Save the Bare_Plugin.java to anywhere in your computer by File > Save. Image010.png

  1. Save .jar in the plugins folder 7. Then, export the code as a Bare_Plugin.jar file (Java Archive) in the plugins folder (Fiji.app\plugins) by File > Export as .jar. Image011.png

Image012.png

8. There will be a Java error, but just ignore it. Image013.png

Image014.png

9. Now you can find the Bare_plugin.jar file in the plugins folder. Image015.png

  1. Run the plugin 10. Re-lauch ImageJ/Fiji. Image016.png

11. Go Plugins > Bare Plugin to run the plugin. Image018.png

12. There you go! You can see the Hello World message showing up. Image019.png

Recommended Posts

Hallo Welt für ImageJ Java Plugin
Java, Hallo Welt!
Java Hallo Welt
"Hallo Welt" für ImageJ mit Eclipse
Java lernen (1) -Hallo Welt
Hallo Welt in Java
Java Hallo Welt, kompilieren, ausführen
Java-Anfänger lesen Hello World
Hallo Welt mit AWS Lambda + Java
Hallo Welt von Java in Eclipse jetzt
Hallo Welt in Java und Gradle
Erstellen einer Elasticsearch-Plugin-Serie (1) Hello World
Java-Entwicklung mit Codenvy: Hello World! Run
Hallo Welt auf Mac VSCode Java
Praktisches Plug-In für die Eclipse JAVA-Entwicklung: Decompiler
Minimale Java-Umgebungskonstruktion und Hello World
Für JAVA-Lernen (2018-03-16-01)
Lesen Sie "Hallo Welt"
2017 IDE für Java
Hallo Java Lambda
Erste Programmierung in meinem Leben Java 1st Hello World
Java für Anweisung
Erstellen Sie eine Java-Umgebung und geben Sie Hallo Welt aus [Anfänger]
[Java] Hallo Welt mit Java 14 x Spring Boot 2.3 x JUnit 5 ~
Zeigen Sie "Hello World" im Browser mit Java an
Zeigen Sie "Hello World" im Browser mit Java an
Liste verschwenderisch kreativer "Hello World" -Ausgabemethoden (Java)
[Java] für Anweisung, während Anweisung
[Java] Paket für die Verwaltung
[Java] für Anweisung / erweitert für Anweisung
Lesen Sie System.out.println ("Hallo Welt")
Schreiben wir Hello World
Gegenmaßnahmen für OutOfMemoryError in Java
NLP für Java (NLP4J) (2)
Java-Teil 1-Hallo Welt studieren
(Memo) Java für Anweisung
NLP für Java (NLP4J) (1)
Plug-In-Entwicklung mit ImageJ
Hallo Welt mit Web Assembly
Hallo Welt mit Micronaut
[Java] Eine Art von Alphabet verboten Mit Bindung Hallo, Welt! [Bindung]
Versuchen Sie Hello World mit einfachem Java im Docker-Container
Hallo Welt mit Spring Boot
Java-Geschichte in dieser Welt
[Gradle] Informationen zu Java-Plug-In-Aufgaben
Java-Debug-Ausführung [für Java-Anfänger]
[Java] Grundlegende Aussage für Anfänger
Hallo Welt mit Spring Boot!
Hallo Welt mit VS Code!
2018 Java Proficiency Test für Newcomer-Basics-
Java-Thread sicher für Sie
Hallo Welt mit Spring Boot
Java für Anfänger, Daten verstecken
[Java] Tipps zum Schreiben der Quelle
Java-Installationsort für Mac
Hallo Welt mit SpringBoot / Gradle
Java-Anwendung für Anfänger: Stream
Java während und für Anweisungen