# jfinal check whether "tools.jar" is in the environment variable CLASSPATH

> java访问报错： 第一次的时候还能正常使用，编译之后报错 jfinal Can not get javax.tools.JavaCompiler, check whether "tools.jar" is in the environme…

- 原文：https://www.l2qq.com/article/91
- 发布：2019-11-11T02:47:29Z
- 更新：2020-06-12T09:51:01Z
- 作者：l2qq

---

java访问报错：
第一次的时候还能正常使用，编译之后报错
jfinal Can not get javax.tools.JavaCompiler, check whether "tools.jar" is in the environment variable CLASSPATH
原因：

https://www.jfinal.com/doc/4-8
添加了注入Proxy 动态代理，需要：在main添加代码：
```
public void configConstant(Constants me) {
// 4.6 之前的版本的配置方式: me.setProxyFactory(new CglibProxyFactory());
me.setToCglibProxyFactory(); // 4.6 版本新增配置方式
}
pom.xml添加依赖
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>3.2.5</version>
</dependency>
```
```
2019-11-11 10:15:32
[ERROR]-[Thread: XNIO-1 task-1]-[com.jfinal.core.ActionHandler.handle()]: com.wx.room.RoomController.findById() : /room/findById
java.lang.RuntimeException: Can not get javax.tools.JavaCompiler, check whether "tools.jar" is in the environment variable CLASSPATH
at com.jfinal.proxy.ProxyCompiler.compile(ProxyCompiler.java:131)
at com.jfinal.proxy.ProxyFactory.getProxyClass(ProxyFactory.java:69)
at com.jfinal.proxy.ProxyFactory.get(ProxyFactory.java:41)
at com.jfinal.proxy.Proxy.get(Proxy.java:32)
at com.jfinal.aop.AopFactory.createObject(AopFactory.java:173)
at com.jfinal.aop.AopFactory.doGetSingleton(AopFactory.java:87)
at com.jfinal.aop.AopFactory.doGet(AopFactory.java:65)
at com.jfinal.aop.AopFactory.doInject(AopFactory.java:157)
at com.jfinal.aop.AopFactory.inject(AopFactory.java:125)
at com.jfinal.aop.Aop.inject(Aop.java:105)
at com.jfinal.core.ActionHandler.handle(ActionHandler.java:84)
at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:89)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.A
```
