本文整理汇总了Java中org.eclipse.jdt.internal.compiler.batch.Main类的典型用法代码示例。如果您正苦于以下问题:Java Main类的具体用法?Java Main怎么用?Java Main使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Main类属于org.eclipse.jdt.internal.compiler.batch包,在下文中一共展示了Main类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addFilesFrom
import org.eclipse.jdt.internal.compiler.batch.Main; //导入依赖的package包/类
private void addFilesFrom(File javaHome, String propertyName, String defaultPath, ArrayList<File> files) {
String extdirsStr = System.getProperty(propertyName);
File[] directoriesToCheck = null;
if (extdirsStr == null) {
if (javaHome != null) {
directoriesToCheck = new File[] { new File(javaHome, defaultPath) };
}
} else {
StringTokenizer tokenizer = new StringTokenizer(extdirsStr, File.pathSeparator);
ArrayList<String> paths = new ArrayList<String>();
while (tokenizer.hasMoreTokens()) {
paths.add(tokenizer.nextToken());
}
if (paths.size() != 0) {
directoriesToCheck = new File[paths.size()];
for (int i = 0; i < directoriesToCheck.length; i++) {
directoriesToCheck[i] = new File(paths.get(i));
}
}
}
if (directoriesToCheck != null) {
addFiles(Main.getLibrariesFiles(directoriesToCheck), files);
}
}
示例2: callECJ
import org.eclipse.jdt.internal.compiler.batch.Main; //导入依赖的package包/类
/**
* Calls the ECJ and wraps any errors in a {@link CompilerException}
*
* @param args Arguments for the compiler
* @throws CompilerException if compilation fails
*/
private void callECJ(String args[])
{
Log log = LogFactory.getLog(COMPILER_LOG);
log.trace(Arrays.deepToString(args));
StringWriter output = new StringWriter();
StringWriter errors = new StringWriter();
Main compiler = new Main(new PrintWriter(output), new PrintWriter(errors), false);
compiler.compile(args);
String message = errors.toString();
if (message.length() > 0)
{
String error = "Errors found during compilation:\n" + message;
throw new CompilerException(error, message);
}
}
示例3: getClasspath
import org.eclipse.jdt.internal.compiler.batch.Main; //导入依赖的package包/类
private List getClasspath() throws IllegalStateException {
Main main =
new Main(
new PrintWriter(System.out),
new PrintWriter(System.err),
false /*systemExit*/,
null /*options*/,
null /*progress*/);
ArrayList allClasspaths = new ArrayList();
try {
if ((this.bits & CompilationUnitResolver.INCLUDE_RUNNING_VM_BOOTCLASSPATH) != 0) {
org.eclipse.jdt.internal.compiler.util.Util.collectRunningVMBootclasspath(allClasspaths);
}
if (this.sourcepaths != null) {
for (int i = 0, max = this.sourcepaths.length; i < max; i++) {
String encoding = this.sourcepathsEncodings == null ? null : this.sourcepathsEncodings[i];
main.processPathEntries(
Main.DEFAULT_SIZE_CLASSPATH,
allClasspaths,
this.sourcepaths[i],
encoding,
true,
false);
}
}
if (this.classpaths != null) {
for (int i = 0, max = this.classpaths.length; i < max; i++) {
main.processPathEntries(
Main.DEFAULT_SIZE_CLASSPATH, allClasspaths, this.classpaths[i], null, false, false);
}
}
ArrayList pendingErrors = main.pendingErrors;
if (pendingErrors != null && pendingErrors.size() != 0) {
throw new IllegalStateException("invalid environment settings"); // $NON-NLS-1$
}
} catch (IllegalArgumentException e) {
throw new IllegalStateException("invalid environment settings"); // $NON-NLS-1$
}
return allClasspaths;
}
示例4: getPathsFrom
import org.eclipse.jdt.internal.compiler.batch.Main; //导入依赖的package包/类
private Iterable<? extends File> getPathsFrom(String path) {
ArrayList<FileSystem.Classpath> paths = new ArrayList<FileSystem.Classpath>();
ArrayList<File> files = new ArrayList<File>();
try {
this.processPathEntries(Main.DEFAULT_SIZE_CLASSPATH, paths, path, this.charset.name(), false, false);
} catch (IllegalArgumentException e) {
return null;
}
for (FileSystem.Classpath classpath : paths) {
files.add(new File(classpath.getPath()));
}
return files;
}
示例5: getDefaultBootclasspath
import org.eclipse.jdt.internal.compiler.batch.Main; //导入依赖的package包/类
Iterable<? extends File> getDefaultBootclasspath() {
ArrayList<File> files = new ArrayList<File>();
String javaversion = System.getProperty("java.version");//$NON-NLS-1$
if(javaversion.length() > 3)
javaversion = javaversion.substring(0, 3);
long jdkLevel = CompilerOptions.versionToJdkLevel(javaversion);
if (jdkLevel < ClassFileConstants.JDK1_6) {
// wrong jdk - 1.6 or above is required
return null;
}
/*
* Handle >= JDK 1.6
*/
String javaHome = System.getProperty("java.home"); //$NON-NLS-1$
File javaHomeFile = null;
if (javaHome != null) {
javaHomeFile = new File(javaHome);
if (!javaHomeFile.exists())
javaHomeFile = null;
}
addFilesFrom(javaHomeFile, "java.endorsed.dirs", "/lib/endorsed", files);//$NON-NLS-1$//$NON-NLS-2$
if (javaHomeFile != null) {
File[] directoriesToCheck = null;
if (System.getProperty("os.name").startsWith("Mac")) {//$NON-NLS-1$//$NON-NLS-2$
directoriesToCheck = new File[] { new File(javaHomeFile, "../Classes"), //$NON-NLS-1$
};
} else {
directoriesToCheck = new File[] { new File(javaHomeFile, "lib") //$NON-NLS-1$
};
}
File[][] jars = Main.getLibrariesFiles(directoriesToCheck);
addFiles(jars, files);
}
addFilesFrom(javaHomeFile, "java.ext.dirs", "/lib/ext", files);//$NON-NLS-1$//$NON-NLS-2$
return files;
}
示例6: getEndorsedDirsFrom
import org.eclipse.jdt.internal.compiler.batch.Main; //导入依赖的package包/类
private Iterable<? extends File> getEndorsedDirsFrom(String path) {
ArrayList<FileSystem.Classpath> paths = new ArrayList<FileSystem.Classpath>();
ArrayList<File> files = new ArrayList<File>();
try {
this.processPathEntries(Main.DEFAULT_SIZE_CLASSPATH, paths, path, this.charset.name(), false, false);
} catch (IllegalArgumentException e) {
return null;
}
for (FileSystem.Classpath classpath : paths) {
files.add(new File(classpath.getPath()));
}
return files;
}
示例7: getExtdirsFrom
import org.eclipse.jdt.internal.compiler.batch.Main; //导入依赖的package包/类
private Iterable<? extends File> getExtdirsFrom(String path) {
ArrayList<FileSystem.Classpath> paths = new ArrayList<FileSystem.Classpath>();
ArrayList<File> files = new ArrayList<File>();
try {
this.processPathEntries(Main.DEFAULT_SIZE_CLASSPATH, paths, path, this.charset.name(), false, false);
} catch (IllegalArgumentException e) {
return null;
}
for (FileSystem.Classpath classpath : paths) {
files.add(new File(classpath.getPath()));
}
return files;
}
示例8: setLocale
import org.eclipse.jdt.internal.compiler.batch.Main; //导入依赖的package包/类
public void setLocale(Locale locale) {
this.locale = locale == null ? Locale.getDefault() : locale;
try {
this.bundle = ResourceBundleFactory.getBundle(this.locale);
} catch(MissingResourceException e) {
System.out.println("Missing resource : " + Main.bundleName.replace('.', '/') + ".properties for locale " + locale); //$NON-NLS-1$//$NON-NLS-2$
throw e;
}
}
示例9: bind
import org.eclipse.jdt.internal.compiler.batch.Main; //导入依赖的package包/类
private String bind(String id, String[] arguments) {
if (id == null)
return "No message available"; //$NON-NLS-1$
String message = null;
try {
message = this.bundle.getString(id);
} catch (MissingResourceException e) {
// If we got an exception looking for the message, fail gracefully by just returning
// the id we were looking for. In most cases this is semi-informative so is not too bad.
return "Missing message: " + id + " in: " + Main.bundleName; //$NON-NLS-2$ //$NON-NLS-1$
}
return MessageFormat.format(message, (Object[]) arguments);
}
示例10: configure
import org.eclipse.jdt.internal.compiler.batch.Main; //导入依赖的package包/类
@Override
public void configure(Object batchCompiler, String[] commandLineArguments) {
if (null != _processingEnv) {
throw new IllegalStateException(
"Calling configure() more than once on an AnnotationProcessorManager is not supported"); //$NON-NLS-1$
}
BatchProcessingEnvImpl processingEnv = new BatchProcessingEnvImpl(this, (Main) batchCompiler, commandLineArguments);
_processingEnv = processingEnv;
_procLoader = processingEnv.getFileManager().getClassLoader(StandardLocation.ANNOTATION_PROCESSOR_PATH);
parseCommandLine(commandLineArguments);
_round = 0;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:BatchAnnotationProcessorManager.java
示例11: run
import org.eclipse.jdt.internal.compiler.batch.Main; //导入依赖的package包/类
@Override
public int run(InputStream in, OutputStream out, OutputStream err, String... arguments) {
boolean succeed = new Main(
new PrintWriter(new OutputStreamWriter(out != null ? out : System.out)),
new PrintWriter(new OutputStreamWriter(err != null ? err : System.err)),
true/* systemExit */,
null/* options */,
null/* progress */).compile(arguments);
return succeed ? 0 : -1;
}
示例12: getClasspath
import org.eclipse.jdt.internal.compiler.batch.Main; //导入依赖的package包/类
private List getClasspath() throws IllegalStateException {
Main main = new Main(new PrintWriter(System.out), new PrintWriter(System.err), false/*systemExit*/, null/*options*/, null/*progress*/);
ArrayList allClasspaths = new ArrayList();
try {
if ((this.bits & CompilationUnitResolver.INCLUDE_RUNNING_VM_BOOTCLASSPATH) != 0) {
org.eclipse.jdt.internal.compiler.util.Util.collectRunningVMBootclasspath(allClasspaths);
}
if (this.sourcepaths != null) {
for (int i = 0, max = this.sourcepaths.length; i < max; i++) {
String encoding = this.sourcepathsEncodings == null ? null : this.sourcepathsEncodings[i];
main.processPathEntries(
Main.DEFAULT_SIZE_CLASSPATH,
allClasspaths, this.sourcepaths[i], encoding, true, false);
}
}
if (this.classpaths != null) {
for (int i = 0, max = this.classpaths.length; i < max; i++) {
main.processPathEntries(
Main.DEFAULT_SIZE_CLASSPATH,
allClasspaths, this.classpaths[i], null, false, false);
}
}
ArrayList pendingErrors = main.pendingErrors;
if (pendingErrors != null && pendingErrors.size() != 0) {
throw new IllegalStateException("invalid environment settings"); //$NON-NLS-1$
}
} catch (IllegalArgumentException e) {
throw new IllegalStateException("invalid environment settings"); //$NON-NLS-1$
}
return allClasspaths;
}
示例13: getDefaultBootclasspath
import org.eclipse.jdt.internal.compiler.batch.Main; //导入依赖的package包/类
Iterable<? extends File> getDefaultBootclasspath() {
ArrayList<File> files = new ArrayList<File>();
String javaversion = System.getProperty("java.version");//$NON-NLS-1$
if (javaversion != null && !javaversion.startsWith("1.6")) { //$NON-NLS-1$
// wrong jdk - 1.6 is required
return null;
}
/*
* Handle >= JDK 1.6
*/
String javaHome = System.getProperty("java.home"); //$NON-NLS-1$
File javaHomeFile = null;
if (javaHome != null) {
javaHomeFile = new File(javaHome);
if (!javaHomeFile.exists())
javaHomeFile = null;
}
addFilesFrom(javaHomeFile, "java.endorsed.dirs", "/lib/endorsed", files);//$NON-NLS-1$//$NON-NLS-2$
if (javaHomeFile != null) {
File[] directoriesToCheck = null;
if (System.getProperty("os.name").startsWith("Mac")) {//$NON-NLS-1$//$NON-NLS-2$
directoriesToCheck = new File[] { new File(javaHomeFile, "../Classes"), //$NON-NLS-1$
};
} else {
directoriesToCheck = new File[] { new File(javaHomeFile, "lib") //$NON-NLS-1$
};
}
File[][] jars = Main.getLibrariesFiles(directoriesToCheck);
addFiles(jars, files);
}
addFilesFrom(javaHomeFile, "java.ext.dirs", "/lib/ext", files);//$NON-NLS-1$//$NON-NLS-2$
return files;
}
示例14: parseCommandLine
import org.eclipse.jdt.internal.compiler.batch.Main; //导入依赖的package包/类
private void parseCommandLine(String[] args) throws InvalidInputException {
StringWriter err = new StringWriter();
Main driver = new Main(null, new PrintWriter(err), false);
driver.configure(args);
StringBuffer buffer = err.getBuffer();
if (buffer.length() != 0) {
throw new InvalidInputException(buffer.toString());
}
sourceFilePaths = driver.filenames;
compilerOptions = driver.options;
classPath = driver.getLibraryAccess();
}
示例15: compile
import org.eclipse.jdt.internal.compiler.batch.Main; //导入依赖的package包/类
protected boolean compile(String arguments) {
// return BatchCompiler.compile(sb.toString(), new PrintWriter(new
// OutputStreamWriter(System.out)), new PrintWriter(
// new OutputStreamWriter(errorStream)), null);
return getMain().compile(Main.tokenize(arguments));
}