For Windows 7, I\'ve installed JDK in both 32 and 64 bit versions. The versions are 8, update 20 for all four installations. http://www.oracle.com/technetwork/java/javase/d
This is pretty common error, JAVA_HOME environment is not set. So, we need to set it up in a more prominent basis. What it's asking for the path to the jre directory and not to the bin directory i.e. java environment path to configure & run the elasticsearch. So, make sure you don't specify the bin directory into your path. Then, you are good to go run your elasticsearch and it will be up and running at default port 9200.
If elasticsearch version is 7.5 or higher, you find elasticsearch-7.X.Y\bin directory and then edit the elasticsearch-env.bat as the following:
if defined JAVA_HOME (
set JAVA="%WRITE_ELASTICSEARCH_JAVA_PATH%\bin\java.exe" //write java custom path. Edit only this line
set JAVA_TYPE=JAVA_HOME
) else (
set JAVA="%ES_HOME%\jdk\bin\java.exe"
set JAVA_HOME="%ES_HOME%\jdk"
set JAVA_TYPE=bundled jdk
)
You can customize the java path like that for elasticsearch.
A workaround if you do not have privileges to set up the environmental variables:
open the elasticsearch.bat file,
a) Remove the line:
if NOT DEFINED JAVA_HOME goto err
b) Replace %JAVA_HOME% with your java jdk path, something like: C:\Program Files\Java\jdk1.7.0_51
And for your terminal getting started and you not being able to type anything, it is the elasticsearch server, you need to connect to it using a client like cygwin.
https://cygwin.com/install.html
For connecting to the server refer the elasticsearch documentation.
http://www.elasticsearch.org/guide/
A similar question has already been answered:
"JAVA_HOME points to an invalid Java installation issue" with service install command in elastic search
run the below command:
set JAVA_HOME=C:\Program Files\Java\jre8
See , you just need to do below: (don't delete any environment variable already set)
I still couldn't run it even after I set the %JAVA_HOME%
environment variable. The problem for me was that I should have ran the elasticsearch.bat
file as an administrator. That fixed the issue.