// Prepare a command to launch the tool.
Commandline cmd = setupCommand(javah);
cmd.setExecutable(clss.getName());
// Prepare a java command.
ExecuteJava java = new ExecuteJava();
java.setJavaCommand(cmd);
// Find a file or a jar which represents the required class.
File file = Locator.getClassSource(clss);
if (file != null) {
// The found file should be included into the class path.
Path classpath = new Path(javah.getProject(), file.getPath());
// Try to load BCEL's ClassPath utility class.
try {
clss = Class.forName("org.apache.bcel.util.ClassPath");
} catch (ClassNotFoundException e) {
throw new BuildException("Can't load BCEL", e,
javah.getLocation());
}
// Find a file or a jar which represents the required class.
file = Locator.getClassSource(clss);
if (file != null) {
// Add the found file to the class path.
classpath.append(new Path(javah.getProject(), file.getPath()));
}
// Set the class path.
java.setClasspath(classpath);
}
// Run the java command.
return java.fork(javah) == 0;
}