Я использую JavaCompiler из пакета javax.tools(JDK 1.7) для компиляции некоторых вещей "на лету", например:
compiler.run(null, null, "-cp", paths, "path/to/my/file.java");
Это работает, но я хотел бы сделать все это в памяти (например, передать строку с кодом, а не исходным файлом, и вернуть код байта не как .class файл). Я обнаружил, что расширение параметров InputStream
и OutputStream
бесполезно, так как оно, вероятно, такое же, как в консоли. Знаете ли вы, как заставить метод run работать так? Или вы знаете, как это сделать с помощью метода getTask()
? (расширение FileManager выглядит легко, но это не так просто:)