[英]Ant -verbose fails with “package does not exist” despite jar being on classpath
I have the following code 我有以下代码
package myPackage;
import org.neo4j.graphdb;
import org.neo4j.kernel.EmbeddedGraphDatabase;
public class dbServlet extends HttpServlet {
public void init() throws ServletException {
// Start up the database here
GraphDatabaseService graphDb = new EmbeddedGraphDatabase("var/base");
}
public void destroy() {
graphDb.shutdown();
}
and build.xml file: 和build.xml文件:
<project name="dbServlet" basedir="." default="compile">
<property name="src.dir" value="src"/>
<property name="lib.dir" value="lib"/>
<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="${build.dir}/jar"/>
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<target name="compile">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
</target>
</project>
All of the neo4j jars are located in a lib directory where the build.xml file is. 所有neo4j jar都位于build.xml文件所在的lib目录中。 The source is located at src/myPackage/dbServlet.java.
源位于src / myPackage / dbServlet.java。 When I run ant -v, the classpath includes the jars that have the neo4j classes, but javac is saying the packages don't exist.
当我运行ant -v时,类路径包括具有neo4j类的jar,但是javac表示这些包不存在。 Anyone know why this could be?
有人知道为什么会这样吗?
Heres a snippet of the errors (I'm concerned with the first one for now, I know that the servlet api's aren't on the path yet): 以下是错误的摘要(我现在关注第一个错误,我知道servlet api尚未出现在路径中):
[javac] /home/shaun/projects/helloAnt/src/myPackage/dbServlet.java:3: package org.neo4j does not exist
[javac] import org.neo4j.graphdb;
[javac] ^
[javac] /home/shaun/projects/helloAnt/src/myPackage/dbServlet.java:6: cannot find symbol
[javac] symbol: class HttpServlet
[javac] public class dbServlet extends HttpServlet {
[javac] ^
[javac] /home/shaun/projects/helloAnt/src/myPackage/dbServlet.java:8: cannot find symbol
[javac] symbol : class ServletException
[javac] location: class myPackage.dbServlet
[javac] public void init() throws ServletException {
[javac] ^
It looks to me like your import is not quite right - do you want to import all the classes in the org.neo4j.graphdb
package? 在我看来,您的导入不太正确-您是否要导入
org.neo4j.graphdb
包中的所有类?
import org.neo4j.graphdb.*;
Else you should give a specific class name. 否则,您应该指定一个特定的类名。 The javac error message indicates that a package
org.neo4j
is being sought - graphdb is being treated as a class name. javac错误消息指示正在搜索软件包
org.neo4j
-graphdb被视为类名。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.