I’ve been playing around with Neo4j on a Windows VM recently and I wanted to launch neo4j-shell to run a few queries.
The neo4j-shell script isn’t shipped with Neo4j desktop which I used to install Neo4j on my VM but we can still launch it from the Windows Command Prompt with the following command:
C:\Users\Mark> cd "C:\Program Files\Neo4j Community" C:\Program Files\Neo4j Community>jre\bin\java -cp bin\neo4j-desktop-2.0.0-RC1.jar org.neo4j.shell.StartClient Welcome to the Neo4j Shell! Enter 'help' for a list of commands NOTE: Remote Neo4j graph database service 'shell' at port 1337 Want bash-like features? throw in jLine (http://jline.sourceforge.net) on the classpath
Unfortunately if we start typing in a query we don’t get any feedback as to what we’re typed, although if we type something syntactically valid and suffix it with a semi colon and press enter it will be evaluated!
e.g. this is the output from entering the following query
START n = node(*) RETURN COUNT(n);
The reason for the problem is to do with the ‘.shell_history’ file that the shell tries to write to the directory it’s launched from. In this case we don’t have permission to write anything to ‘C:\Program Files\Neo4j Community’ and so we get no feedback.
To workaround this problem we need to start the command prompt as an administrator which we can do from the apps menu by right clicking the ‘Command Prompt’ icon:
Next we click ‘Start as Administrator’ and click through the next screen:
Now if we launch neo4j-shell and type in our query we get the expected feedback: