Re: Path Problem?
Posted by Bob Loushin on Jan 19, 2010; 1:11am
URL: http://imagej.273.s1.nabble.com/Path-problem-tp3689668p3689669.html
I'd like to thank everyone who responded. Mr. Saalfeld seems to have pointed me down the right path, but I haven't had success following it. In particular, the following works:
Experiment 1:
test_1.java:
//package my_stuff;
import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;
public class test_1 implements PlugIn {
public void run(String arg) { shared_method(); }
public void shared_method() { IJ.showMessage("test_1","Hello world!"); }
}
plugins.config:
# Name: Test_Plugin
# Author: Bob
# Version: 1.0
# Date: 1/18/10
# Requires: ImageJ 1.31s
Plugins>Test, "Test 1", test_1("run")
I compile a .class out of the java file using ImageJ>Plugins>Compile and Run..., wrap the whole thing in a .jar using the command
jar cvfM Test.jar test_1.class test_1.java plugins.config
I put this in the plugins folder, fired up ImageJ, and Test 1 was there and ran as expected.
Experiment 2: Then I uncommented the first line of the .java file and changed the last line of the plugins.config to read
Plugins>Test, "Test 1", my_stuff.test_1("run")
I compile the .class, but of course when I do the Compile and Run..., the run part fails, because now my class is inside a package. But it still compiled, and the .class should be good, so I proceed. I use the same jar command as before, restart ImageJ, and try to run it. Unfortunately, it again fails. Apparently, there is still a detail I do not understand.
Experiment 3: The ultimate goal is to be able to write a test_2.java which will look like the following:
test_2.java:
//package my_stuff;
import test_1.*; //This line may not be necessary, or it might need to be import test_1; my Java knowledge is weak on this point, but I'll experiment.
import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;
public class test_2 implements PlugIn {
public void run(String arg) {
test_1 temp;
temp.shared_method();
}
}
I can't try this until I can get Experiment 2 to work.
Can anyone tell me where I've gone wrong?
Thanks!
Bob