views:

33

answers:

1

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:

<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. The source is located at 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. 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):

[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]                               ^
+3  A: 

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?

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.

martin clayton
Life saver, I've been staring at this thing for hours... Added the star and it works. Thanks
Shaun
aw, you beat me. just found http://api.neo4j.org/current/org/neo4j/graphdb/package-summary.html. good one
JoseK