---
title: "Unable to compile class for JSP"
author: "laies"
date: "2009-01-03T16:03:47Z"
tags: []
slug: "unable-to-compile-class-for-jsp"
draft: false
lastmod: "2009-01-03T16:03:47Z"
id: 309186
url: "https://laies.iteye.com/blog/309186"
---

使用jsp:userBean是出现了Unable to compile class for JSP错误问题：

org.apache.jasper.JasperException: Unable to compile class for JSP

No Java compiler was found to compile the generated source for the JSP. 
This can usually be solved by copying manually $JAVA_HOME/lib/tools.jar
from the JDK to the common/lib directory of the Tomcat server, 
followed by a Tomcat restart. If using an alternate Java compiler, 
please check its installation and access path.

解决方法：


1.     将安装目录"Tomcat 6.0\webapps\examples\WEB-INF\lib"下   的"jstl.jar"和"standard.jar"两个包复制到"Tomcat 6.0\lib"目录下即可


2、 按照提示拷贝tools.jar到相应目录，restart tomcat，看行不行


3、 更换jdk版本，从1.4.2.04到1.4.2.08再到1.5.0，看行不行


4、 检查JAVA_HOME和 CATALINA_HOME，看有没有问题


5.    出现这个问题的原因是因为在classes中没有放置包文件的缘故，就是因为把类直接放在classes文件下就出现无法编译通过解决方法：不要直接在default package下创建类文件，新建一个package，如pack，然后再创建类，保存就可以了