本文整理汇总了Java中com.sun.tools.javah.Main类的典型用法代码示例。如果您正苦于以下问题:Java Main类的具体用法?Java Main怎么用?Java Main使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Main类属于com.sun.tools.javah包,在下文中一共展示了Main类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import com.sun.tools.javah.Main; //导入依赖的package包/类
void test(String... args)
throws IOException, InterruptedException
{
String[] cp_args = new String[args.length + 2];
cp_args[0] = "-classpath";
cp_args[1] = testClasses.getPath();
System.arraycopy(args, 0, cp_args, 2, args.length);
if (jdk != null)
init(cp_args);
File out = null;
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-o")) {
out = new File(args[++i]);
break;
} else if (args[i].equals("-d")) {
out = new File(args[++i]);
out.mkdirs();
break;
}
}
try {
System.out.println("test: " + Arrays.asList(cp_args));
// // Uncomment and use the following lines to execute javah via the
// // command line -- for example, to run old javah and set up the golden files
// List<String> cmd = new ArrayList<String>();
// File javaHome = new File(System.getProperty("java.home"));
// if (javaHome.getName().equals("jre"))
// javaHome = javaHome.getParentFile();
// File javah = new File(new File(javaHome, "bin"), "javah");
// cmd.add(javah.getPath());
// cmd.addAll(Arrays.asList(cp_args));
// ProcessBuilder pb = new ProcessBuilder(cmd);
// pb.redirectErrorStream(true);
// pb.start();
// Process p = pb.start();
// String line;
// BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
// while ((line = in.readLine()) != null)
// System.err.println(line);
// in.close();
// int rc = p.waitFor();
// Use new javah
PrintWriter err = new PrintWriter(System.err, true);
int rc = Main.run(cp_args, err);
if (rc != 0) {
error("javah failed: rc=" + rc);
return;
}
// The golden files use the LL suffix for long constants, which
// is used on Linux and Solaris. On Windows, the suffix is i64,
// so compare will update the golden files on the fly before the
// final comparison.
compare(new File(new File(testSrc, "gold"), out.getName()), out);
} catch (Throwable t) {
t.printStackTrace();
error("javah threw exception");
}
}