package com.online.common; import java.io.File; import java.util.ArrayList; import java.util.List; import org.apache.commons.jci.compilers.CompilationResult; import org.apache.commons.jci.compilers.EclipseJavaCompiler; import org.apache.commons.jci.compilers.EclipseJavaCompilerSettings; import org.apache.commons.jci.problems.CompilationProblem; import org.apache.commons.jci.readers.FileResourceReader; import org.apache.commons.jci.stores.FileResourceStore; public class WebJavaComilper { private String version = "1.8"; private String JavaPath ; private String javaName; public List<String> comilper() { File file = new File(JavaPath); List<String> result = new ArrayList<String>(); EclipseJavaCompilerSettings setting = new EclipseJavaCompilerSettings(); setting.setSourceVersion("1.7"); setting.setTargetVersion("1.7"); EclipseJavaCompiler javaCompiler = new EclipseJavaCompiler(setting); ClassLoader loader = Thread.currentThread().getContextClassLoader(); FileResourceReader reader = new FileResourceReader(file); FileResourceStore store = new FileResourceStore(file); CompilationResult cr = javaCompiler.compile(new String[] {javaName + ".java"}, reader, store,loader); CompilationProblem[] cp = cr.getErrors(); for (CompilationProblem tmp : cp) { result.add(tmp.getMessage() +":"+tmp.getStartLine()); } return result; } public String getVersion() { return version; } public void setVersion(String version) { this.version = version; } public String getJavaPath() { return JavaPath; } public void setJavaPath(String javaPath) { JavaPath = javaPath; } public String getJavaName() { return javaName; } public void setJavaName(String javaName) { this.javaName = javaName; } }

superman1420152584 LV1
2022年6月2日
crosa_Don LV18
2022年4月1日
945506100 LV2
2021年9月9日
JevahChao LV1
2021年6月22日
H.13-1.15 LV1
2021年5月18日
814035682 LV1
2021年1月29日
1736105pxr LV1
2021年1月25日
qiushicun LV1
2020年12月9日
luocheng LV18
2020年11月8日
a1140038335 LV1
2020年10月6日

3334004690 LV10
2024年6月24日
求学的熊猫 LV11
2024年5月12日
denglu123321 LV4
2023年12月27日
2890892945 LV2
2023年12月26日
qq1357574774 LV2
2023年7月20日
dmyafda LV5
2023年3月26日
柴0000
2023年3月19日
暂无贡献等级
ApolloLee
2023年2月23日
暂无贡献等级
大无语 LV1
2023年1月4日
王俊杰1
2022年9月22日
暂无贡献等级