title: Neo4J Server Installation Linux AWS Centos OS -- service user cannot find java
body: <p>I have downloaded Neo4J enterprise from the Neo site and have untar'd it under /opt</p>
  
  <p>I have successfully downloaded and installed the Java 7 Server edition from the Oracle web site.  Note after indicating I want a server JRE, Oracle downloads this :  jdk1.7.0_51</p>
  
  <p>I have untar'd both under /opt giving me /opt/neo4j-2.0.0 and /opt/jdk1.7.0_51</p>
  
  <p>I have successfully installed Neo4J 2.O on AWS with Centos Linux, such that it should run as a Service under a service account.  To do this I used the Neo install command.  The command ran successfully</p>
  
  <p>I can successfully start Neo4J as myself.  After editing my ~/.bash_profile to define JAVA_HOME and exporting. </p>
  
  <pre><code>export JAVA_HOME="/opt/jdk1.7.0_51/"
  export NEO4J_HOME="/opt/neo4j-2.0.0"
  export PATH=$JAVA_HOME/bin:$NEO4J_HOME:$PATH
  </code></pre>
  
  <p>Apply
      source ~/.bash_profile</p>
  
  <pre><code>cd /$NEO$J_HOME
  bin/neo4j start
  </code></pre>
  
  <p>Works just fine.</p>
  
  <p>However, we are not able to successfully get Neo to start as a service</p>
  
  <pre><code>sudo service neo4j-service start
  
  which: no java in (/sbin:/usr/sbin:/bin:/usr/bin)
  ERROR: Unable to find java. (Cannot execute )
  * Please use Oracle(R) Java(TM) 7 to run Neo4j Server. Download "Java Platform (JDK) 7" from:
   http://www.oracle.com/technetwork/java/javase/downloads/index.html
  * Please see http://docs.neo4j.org/ for Neo4j Server installation instructions.
  </code></pre>
  
  <p>If I echo $JAVA_HOME it returns as expected
  If I echo $PATH it returns as expected</p>
  
  <p>by as expected we can see java on the path.</p>
  
  <p>If I simply type java -version before I run sudo service neo4j-service start
  the response shows the java version.</p>
  
  <p>A bit of background: the Linux service command is not available unless I first run a special script per our normal it policies.  However, the script clobbers the exports that I would otherwise use.</p>
  
  <p>Accordingly the command
      service neo4j-service start</p>
  
  <p>returns
      -bash: neo4j-service: command not found</p>
  
  <p>indicating that the 'service' command cannot be found</p>
  
  <p>So sudo is required in our environment to execute the service command</p>
  
  <p>We have tried simply placing jdk1.7.0_51  under /sbin/jdk1.7.0_51  that does not work.  We have also tried extracting the jre folder from jdk1.7.0_51 and placing it under /sbin/jre</p>
  
  <p>Also tried creating a java.sh file under /etc/profile.d/ </p>
  
  <p>Still no success.</p>
  
  <p>So the simple question....</p>
  
  <p>Where is Neo4J 2.0.0 looking for Java when running as a service?  Is it using the environment variable JAVA_HOME, or is it looking in one of the following locations as the Neo4J server error message would seem to indicate?   "no java in (/sbin:/usr/sbin:/bin:/usr/bin)"</p>
  
  <p>Under my installation configuration the neo4j service is intended to run under the account neo4jservice.  Is this as simple as making sure JAVA_HOME is available to the neo4jservice accound?  Why the error message "no java in (/sbin:/usr/sbin:/bin:/usr/bin)"?</p>
  
  <p>Thanks in advance</p>