ERLEDIGT
NEIN
NEIN
ANTWORTEN
1
1
ZUGRIFFE
381
381
EMPFEHLEN
-
Ich möchte das encoding setzten beim compilieren zur Laufzeit, laut optionen ist es möglich. Wenn ich die option allerdings setzte sagt er das die Option nicht bekannt ist.
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
public static void main(String args[]) throws IOException { System.out.println("Default Compiler: " + ToolProvider.getSystemJavaCompiler().getClass().getName()); JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>(); StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, Locale.UK, null); Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromStrings(Arrays .asList("src//de//compiler//Hello.java")); JavacOption[] defaultFileManagerOptions = RecognizedOptions .getDefaultFileManagerOptions(new RecognizedOptions.GrumpyHelper()); for (JavacOption o : defaultFileManagerOptions) { System.out.println(o.toString()); System.out.println(o.hasArg()); System.out.println(o.getName()); System.out.println(compiler.isSupportedOption(o.toString())); } System.out.println(compiler.getSourceVersions()); System.out.println(compiler.isSupportedOption("-g")); System.out.println(compiler.isSupportedOption("-verbose")); System.out.println(compiler.isSupportedOption("-target")); System.out.println(compiler.isSupportedOption("-Xlint")); System.out.println(compiler.isSupportedOption(OptionName.ENCODING.name())); List<String> options = new ArrayList<String>(); // options.add("-encoding"); System.out.println(OptionName.ENCODING.name()); System.out.println(new OutputStreamWriter(new ByteArrayOutputStream()).getEncoding()); JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, diagnostics, options, null, compilationUnits); Boolean success = task.call(); for (Diagnostic<?> diagnostic : diagnostics.getDiagnostics()) { System.console().printf( "Code: %s%n" + "Kind: %s%n" + "Position: %s%n" + "Start Position: %s%n" + "End Position: %s%n" + "Source: %s%n" + "Message: %s%n", diagnostic.getCode(), diagnostic.getKind(), diagnostic.getPosition(), diagnostic.getStartPosition(), diagnostic.getEndPosition(), diagnostic.getSource(), diagnostic.getMessage(null)); } fileManager.close(); System.out.println("Success: " + success); }
-
13.10.09 22:25 #2
- Registriert seit
- Jun 2002
- Ort
- Saarbrücken (Saarland)
- Beiträge
- 9.886
- Blog-Einträge
- 29
Hallo,
muss es unbedingt der Sun-Java Compiler sein?
http://www.tutorials.de/forum/java/2...-laufzeit.html
http://www.tutorials.de/forum/java/2...-aufrufen.html
oder sowas:
http://www.tutorials.de/forum/java/1...avaassist.html
Gruß TomJava rocks!
How to become a good Java Programmer?
Does IT in Java and .Net
The only valid measurement of code quality: WTFs / minute
Blog
Xing
Twitter
Ähnliche Themen
-
Compilieren zur Laufzeit
Von Kai Cierpka im Forum JavaAntworten: 6Letzter Beitrag: 28.01.08, 19:06 -
PHP Compilieren
Von aKraus im Forum PHPAntworten: 1Letzter Beitrag: 24.11.06, 10:39 -
Apache Compilieren
Von abla im Forum Hosting & WebserverAntworten: 1Letzter Beitrag: 15.10.04, 00:47 -
compilieren
Von Markus@java im Forum JavaAntworten: 2Letzter Beitrag: 24.03.04, 19:42 -
Von der Eingabeaufforderung Compilieren
Von hunne im Forum C/C++Antworten: 2Letzter Beitrag: 15.07.03, 12:46





Zitieren

Login





