0

I want to rely on JAVA_HOME environment variable to install the Elasticsearch instead want to hardcode the path of java for elasticsearch.I tried hard coding the path in service.bat but it didn't work.Then i looked in some more files in the bin folder of ES elasticsearch.bat and elasticsearch.sh and figured out the the changes to only service.bat wont suffice. Just want to make sure where i need to make the changes as i have very limited knowledge of java.

Thanks

user3775217
  • 4,675
  • 1
  • 22
  • 33

1 Answers1

1

STEP 1

Can you verify that Environment variable JAVA_HOME is set to your JDK,

C:\>echo %JAVA_HOME%

Or, verify java command is available,

java -version

STEP 2

If JAVA_HOME is not set, please follow the steps provided here - How to Set JAVA_HOME in windows

Summary ,

  1. Right-click the My Computer icon on your desktop and select Properties.
  2. Click the Advanced tab. Click the Environment Variables button. Under System Variables, click New.
  3. Enter the variable name as JAVA_HOME.
  4. Enter the variable value as the installation path for the JDK. (eg. C:\Progra~1\Java\jdk1.8.0_20).
  5. Click OK.
  6. Click Apply Changes.

STEP 3

Verify STEP 1 again.

STEP 4

start elasticsearch

Community
  • 1
  • 1
prayagupa
  • 30,204
  • 14
  • 155
  • 192
  • i have java home set in my dev machine and i am able to run the elasticsearch service.my question is to start elasticsearch without setting JAVA_home.I want to hardcode the java installation in one of the bin files for elasticsearch. – user3775217 Sep 26 '14 at 09:32
  • @user3775217 do you have `elasticsearch.bat` file there? – prayagupa Sep 26 '14 at 09:48
  • @user3775217 It's confusing as you said `you want to rely on JAVA_HOME environment variable to install the Elasticsearch` . Maybe you want this => http://stackoverflow.com/a/25349180/432903 – prayagupa Sep 26 '14 at 09:54
  • hmh,,,,i dont want to set java_home variable.Is there any way to hardcode the java installation path for elasticsearch. i just made some changes to service.bat files and i am able to install the service,but the service is getting failed to start. – user3775217 Sep 26 '14 at 10:11
  • @user3775217 did you remove the line `if NOT DEFINED JAVA_HOME goto err` in `service.bat` and replaced `%JAVA_HOME%` with what you want. – prayagupa Sep 26 '14 at 10:34
  • actaully yes,but not in service.bat only.It sets java classpath in other files too,elasticsearch.sh,elasticsearch files.I replaced %JAVA_HOME% in all those files and removed unnecessary if blocks which throws error and made my service up and running. – user3775217 Sep 29 '14 at 16:15