博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Atitit.java eval功能的实现 Compiler API
阅读量:7119 次
发布时间:2019-06-28

本文共 1184 字,大约阅读时间需要 3 分钟。

Atitit.java eval功能的实现  Compiler API

 

 

针对编译器,JDK 设计了两个接口,分别是 JavaCompiler JavaCompiler.CompilationTask

 

 

private static void T() throws FileNotFoundException {

//String fullQuanlifiedFileName = "compile" + java.io.File.separator +

//        "Target.java";     

String fullQuanlifiedFileName=pathx.prjPath()+"/src/aaaaaCompiler/Target.java";

  JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();

 

//  FileOutputStream err = new FileOutputStream("err.txt");

// com.sun.tools.javac.api.JavacTool @2133c8f8  ==compiler  ,

  String string = "-Xlint:deprecation ";

  string ="-d c:\\00output";

int compilationResult = compiler.run(null, null, null,"-d","c:\\00output", fullQuanlifiedFileName);

 

  if(compilationResult == 0){

    System.out.println("Done");

  } else {

    System.out.println("Fail");

  }

}

 

javac: 找不到文件: compile\Target.java

用法: javac <options> <source files>

-help 用于列出可能的选项

Fail

 

输出echo

int compilationResult = compiler.run(null, null, null,"-d","c:\\00output", fullQuanlifiedFileName);

 

输出目录配置

 

作者:: 绰号:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊 ) 

汉字名:艾提拉(艾龙)   EMAIL:1466519819@qq.com

转载请注明来源: http://www.cnblogs.com/attilax/

 

 

参考资料

Java SE 6 新特性_ 编译器 API.html

java动态编译笔记 - 天魂地煞 - 博客园.html

Atiend

 

你可能感兴趣的文章
ANR问题的log位置
查看>>
BeanFactoryPostProcessor接口(容器后处理器)
查看>>
撤销本地的commit
查看>>
Acad::ErrorStatus
查看>>
tar打包/解包用法
查看>>
一个根据相似度的去重方法
查看>>
Tomcat 性能优化
查看>>
增加从mysql
查看>>
对docker隔离性的理解
查看>>
lnmp的环境搭建
查看>>
mysql处理海量数据时的一些优化查询速度方法
查看>>
javaScript的字符串对象
查看>>
heartbeat V2实现MySQL+NFS高可用
查看>>
Netscaler 10.5 VPX与XenApp XenDesktop 集成配置系列之三enable StoreFront Remote Access
查看>>
五步搞定Android开发环境部署——非常详细的Android开发环境搭建教程(转)
查看>>
函数作为参数传递
查看>>
ViolinMemory上市遇低迷 唱衰闪存为哪般?
查看>>
shell脚本-监控系统资源并通过短信报警
查看>>
2014-03-08_javascrit_controller&status
查看>>
SaltStack配置管理之Gains与State测试
查看>>