This action will force synchronization from 老馬/WebJava, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
package Web;import java.util.logging.Level;import java.util.logging.Logger;import javax.tools.JavaCompiler;import javax.tools.ToolProvider;/*** 动态编译Java文件** @author Ma*/public class TplCompile {public String TemplatePath = Options.TemplatePath;/*public static void main(String[] args) {TplCompile Compiler = new TplCompile();Compiler.setTemplatePath();Compiler.run("dd/test.html");}*/public void setTemplatePath() {this.TemplatePath = Options.TemplatePath;}/*** 开始编译*/public Object run(String fileName) {this.setTemplatePath();//先配置路径TemplateCompile templateCompile = new TemplateCompile();int r = templateCompile.start(fileName);if (r > 0 && r == 1) {//1表示说明文件不存在//0表示解析正常return null;}String javaFile = this.TemplatePath + templateCompile.getFilePath(fileName) + "/" + templateCompile.getfileName(fileName) + "Template.java";String classPath = this.getClass().getResource("/").getPath();//动态编译JavaCompiler javac = ToolProvider.getSystemJavaCompiler();int status = javac.run(null, null, null, "-d", classPath, javaFile);if (status != 0) {System.out.println("没有编译成功!");}//动态执行try {//返回与带有给定字符串名的类 或接口相关联的 Class 对象。Class cls = Class.forName("Template." + templateCompile.getFilePath(fileName).replace("/", ".") + templateCompile.getfileName(fileName) + "Template");BaseTemplate object = (BaseTemplate) cls.newInstance();return object;} catch (ClassNotFoundException ex) {Logger.getLogger(TplCompile.class.getName()).log(Level.SEVERE, null, ex);} catch (InstantiationException ex) {Logger.getLogger(TplCompile.class.getName()).log(Level.SEVERE, null, ex);} catch (IllegalAccessException ex) {Logger.getLogger(TplCompile.class.getName()).log(Level.SEVERE, null, ex);}return null;}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。