📄 externaljavacompiler.java
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Library License version 1 published by ozone-db.org.//// The original code and portions created by SMB are// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.//// $Id: ExternalJavaCompiler.java,v 1.2.2.1 2004/01/11 20:42:34 per_nyfelt Exp $package org.ozoneDB.tools.OPP.compiler;import java.util.Collection;import java.util.Arrays;import java.io.IOException;import java.io.InputStreamReader;import java.io.BufferedReader;import java.io.InputStream;/** * Compiles resolver by starting an externalcompiler process. */public class ExternalJavaCompiler extends AbstractJavaCompiler { private String compilerCommand; /** * @param compilerCommand The command to run the compiler.. */ public ExternalJavaCompiler(String compilerCommand) { this.compilerCommand = compilerCommand; } /** * Compiles the classes passed as strings in the classes parameter. * @param classes The classes to compile * @throws CompilerException */ public void compile(Collection classes) throws CompilerException { String args[] = getArguments(compilerCommand, classes); Process process = null; try { process = Runtime.getRuntime().exec(args); process.waitFor(); } catch (IOException e) { throw new CompilerException("Failed to start compiler: " + e.getMessage(), args); } catch (InterruptedException e) { throw new CompilerException("Failed to start compiler: " + e.getMessage(), args); } if (process.exitValue() != 0) { String output = streamToString(process.getInputStream()); String error = streamToString(process.getErrorStream()); // Either plug in a messageWriter or use some other logging (like log4j here) System.out.println("Error running compiler: " + error); System.out.println("compiling source " + getSourcePath() + " to " + getOutputPath()); System.out.println("output: " + output); System.out.println("args: " + Arrays.asList(args)); throw new CompilerException("Failed to compile generated resolver", args); } } private String streamToString(InputStream stream) { BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); String result = null; try { String temp = reader.readLine(); while (temp != null ) { result += " " + temp; temp = reader.readLine(); } } catch (IOException e) { e.printStackTrace(); } return result; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -