我在执行java.lang.ClassNotFoundException: org.apache.bsf.engines.javascript.JavaScriptEngine
(tutorial I'm following)时收到ant build-db-userprofile
。
显然这是因为$ANT_HOME/lib
中没有BSF .jar但是当我执行ls -l $ANT_HOME/lib && ant -version
时我得到以下内容:
-bash-4.1$ ls -l $ANT_HOME/lib
total 0
lrwxrwxrwx. 1 root root 28 May 30 10:03 ant-antlr.jar -> ../../java/ant/ant-antlr.jar
lrwxrwxrwx. 1 root root 34 May 30 10:03 ant-apache-bcel.jar -> ../../java/ant/ant-apache-bcel.jar
lrwxrwxrwx. 1 root root 33 May 30 10:03 ant-apache-bsf.jar -> ../../java/ant/ant-apache-bsf.jar
lrwxrwxrwx. 1 root root 35 May 30 10:03 ant-apache-log4j.jar -> ../../java/ant/ant-apache-log4j.jar
lrwxrwxrwx. 1 root root 33 May 30 10:03 ant-apache-oro.jar -> ../../java/ant/ant-apache-oro.jar
lrwxrwxrwx. 1 root root 36 May 30 10:03 ant-apache-regexp.jar -> ../../java/ant/ant-apache-regexp.jar
lrwxrwxrwx. 1 root root 38 May 30 10:03 ant-apache-resolver.jar -> ../../java/ant/ant-apache-resolver.jar
lrwxrwxrwx. 1 root root 28 May 30 10:02 ant-bootstrap.jar -> ../../java/ant-bootstrap.jar
lrwxrwxrwx. 1 root root 38 May 30 10:03 ant-commons-logging.jar -> ../../java/ant/ant-commons-logging.jar
lrwxrwxrwx. 1 root root 34 May 30 10:03 ant-commons-net.jar -> ../../java/ant/ant-commons-net.jar
lrwxrwxrwx. 1 root root 18 May 30 10:02 ant.jar -> ../../java/ant.jar
lrwxrwxrwx. 1 root root 31 May 30 10:03 ant-javamail.jar -> ../../java/ant/ant-javamail.jar
lrwxrwxrwx. 1 root root 30 May 30 10:03 ant-jdepend.jar -> ../../java/ant/ant-jdepend.jar
lrwxrwxrwx. 1 root root 27 May 30 10:03 ant-jsch.jar -> ../../java/ant/ant-jsch.jar
lrwxrwxrwx. 1 root root 28 May 30 10:03 ant-junit.jar -> ../../java/ant/ant-junit.jar
lrwxrwxrwx. 1 root root 27 May 30 10:02 ant-launcher.jar -> ../../java/ant-launcher.jar
lrwxrwxrwx. 1 root root 29 May 30 10:02 ant-nodeps.jar -> ../../java/ant/ant-nodeps.jar
lrwxrwxrwx. 1 root root 28 May 30 10:03 ant-swing.jar -> ../../java/ant/ant-swing.jar
lrwxrwxrwx. 1 root root 27 May 30 10:03 ant-trax.jar -> ../../java/ant/ant-trax.jar
-bash-4.1$
-bash-4.1$ ant -version
Apache Ant version 1.7.1 compiled on May 10 2016
已经提到的另一种可能性是使用JDK< 1.6,但我使用的是JDK 7.0_79。我的ANT_HOME和ANT_OPTS env变量设置如下:
ANT_HOME=/usr/share/ant
ANT_OPTS=-server -XX:MaxPermSize=256M -Xmx1000m -XX:+UseParallelGC -Xms1000m -XX:SoftRefLRUPolicyMSPerMB=1 -XX:MaxHeapFreeRatio=99
答案 0 :(得分:1)
我通过在主目录中编译和安装ant来解决这个问题。问题可能是因为我正在设置的服务器的设置方式,以及我没有管理员权限的事实。