Suppose there is a Java file that exists in an external folder. Can I write a Java program that will generate the .class file of this Java file and put the .class file in the same external folder?
The easiest way (for me) is to enable tools.jar and call the com.sun.tools.javac.Main.compile( ) function.
tools.jar
com.sun.tools.javac.Main.compile(
yes you can do it with java compiler
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); StandardJavaFileManager fileManager = compiler.getStandardFileManager(null,null,null);
Check it out for more details.
Here: java.lang.Compiler . This class has a compileClass(Class class) and compileClasses(String names) method
java.lang.Compiler
compileClass(Class class)
compileClasses(String names)
Source: https://habr.com/ru/post/1411076/More articles:How to print image in java - javaprint image with actual size in java - javaUITableView appears with empty cells - iosOpenCL: clAmdFft (OpenCL FFT lib from AMD) on NVIDIA GPUs - fftthe border of the CSS element does not work - htmlDjango i18n url does not work with en-us sublanguage - djangoIs it possible to change the folder structure in a Rails project? - restjson string decoding encountered with invalid escape code - jsonSIMBL swizzling in search - objective-cPrimeFaces: Multiple Selection DataTable Doesn't Work - faceletsAll Articles