Jsp运行时报错:“Unable to find a javac compiler ”

来源:互联网 发布:mac系统怎么安装软件 编辑:程序博客网 时间:2024/05/18 06:28
 今天配置Jsp环境变量,因为我前一段时间刚把Servlet囫囵吞枣地看了一遍,自己又用servlet写了一个学生档案管理系统,因为Jsp在tomcat的运行中会自动编译成Servlet,所以我觉得没有必要在去修改什么环境变量,于是我找来一个jsp代码,先运行下看看,结果不行。于是我又按照书本上介绍的把Path路径加上 %JAVA_HOME%/bin,结果还是不行。tomcat始终在报错:
Unable to find a javac compiler; 
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
说是没有找到javac 编译器,可是我明明把Path给改成了JDK的bin目录下了啊。于是我又把JDK bin目录下的javac 拷到Tomcat目录下的bin目录里面,重启tomcat服务器,还是不能运行jsp。这时候我就开始从网上查找原因。果然,网络是个好东西啊,他和我有着同样的原因,他的解决方案是在tomcat的Properties里面的Java Classpath里面加上了%JAVA_HOME%/lib/tools.jar;于是我按照他的方案试了一下,成功了。可是不知道为什么我按书上的方法去修改路径而无效。现在把这位仁兄的方案与大家共享吧。


原文地址:http://blog.zxlm.cn/show-38-1.html

费了我好几天时间,今天终于调好了。在tomcat设置中加入JAVA_HOME/lib/tools.jar就行了,如下图

 

thanks a lot,刚刚碰到,在tomcat 5.0.16中是把tools.jar拷入tomcat的common/lib目录中,到了5.0.28就不行了. ]

thanks,我的问题也解决了:
我是在Eclipse中通过Ant运行cactus测试taglib时遇到的问题:
[junit] Unable to find a javac compiler;
[junit] com.sun.tools.javac.Main is not on the classpath.
[junit] Perhaps JAVA_HOME does not point to the JDK
可是,在外部控制台用Ant调用测试就没问题。我的Tomcat 5.0.27,Ant 1.6.5。

我把tools.jar拷入tomcat的common/lib目录中,问题就解决了。

图片附件: