All Apps and Add-ons

SA-ldapsearch - NameError: name 'JAVA_HOME' is not defined

abpe
Path Finder

I am trying to install SA-ldapsearch on my Win2008R2 search head. I installed the Server JRE and then defined JAVA_HOME=C:\Program Files\jdk1.7.0_25 and added C:\Program Files\jdk1.7.0_25\bin to the path. I restarted Splunk, but still when I try to use any of the ldap searches I get the following error: NameError: name 'JAVA_HOME' is not defined.

Anyone has an idea what's wrong?

Tags (2)
0 Karma
1 Solution

krugger
Communicator

In SA-ldapsearch the commands that are being called are in the bin directory. They seem to be trying to read the following registry keys:

HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\CurrentVersion
HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\($CurrentVersion)\JavaHome

It then tries to call java from the path at JavaHome plus \bin\java. If that fails it will try to read the JAVA_HOME environment variable. If you have something in the registry at those locations your JAVA_HOME will be ignored as it isn't the preferred method to define where Java is.

View solution in original post

cmeo
Contributor

There is actually a bug in the scripts (all of them)

If your keys aren't defined--e.g. the latest server X64 installer for windows uses a tgz, not an MSI, so they're not--this is your fallback:

JAVA_EXECUTABLE = r'%s\bin\java.exe' % os.environ[JAVA_HOME]

No single quotes around JAVA_HOME. It can't work.

I have contacted the maintainer about this.

0 Karma

krugger
Communicator

In SA-ldapsearch the commands that are being called are in the bin directory. They seem to be trying to read the following registry keys:

HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\CurrentVersion
HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\($CurrentVersion)\JavaHome

It then tries to call java from the path at JavaHome plus \bin\java. If that fails it will try to read the JAVA_HOME environment variable. If you have something in the registry at those locations your JAVA_HOME will be ignored as it isn't the preferred method to define where Java is.

abpe
Path Finder

Thanks, I couldn't figure out, why it didn't take my JAVA_HOME, but anyway I created the necessary reg keys in HKLM:SOFTWARE\JavaSoft\Java Runtime Environment. It's working now.

0 Karma

abpe
Path Finder

Thanks for your support, I took a look at the python files and I saw, that it actually searches the windows registry for JAVA_HOME, so I created the necessary entries in HKLM:SOFTWARE\JavaSoft\Java Runtime Environment. Now it works.

0 Karma

abpe
Path Finder

Thanks, the issue is, that for security reasons I don't want to install the jdk-7u25-windows-x64.exe but would like to use the server version here: http://www.oracle.com/technetwork/java/javase/downloads/server-jre7-downloads-1931105.html

0 Karma

linu1988
Champion

Please don't extract it, Do a installation in the default folder. I think JVM is not installed properly. I did some research and i found that in the python files we have paths as C:\Program files(x86)\Java\jdk6/jre6 mentioned by default or it will search for the environment variable. I would urge you to remove the existing folder and delete the env variable. Do a fresh installation with jdk-7u25-windows-x64.exe, then set the environment variable. It should work perfectly.

abpe
Path Finder

It's the Server JRE version, it's a Win-x64 tar.gz, which I just extracted to c:\program files\jdk1.7.0_25.
I tried your suggestion with removing the JAVA_HOME and do the set, but still the issue remains. Are there any logs, I can take a look at, to see what's wrong?

0 Karma

linu1988
Champion

Which version it is? 64-bit/32-bit? Delete the existing JAVA_HOME variable. set JAVA_HOME=C:\Progra~1\Java\jdk1.7.0_25 then check.. because i has the same issue setting up Java_Home.

and where did you install in program files / program files//Java directory?

0 Karma

abpe
Path Finder

It didn't work.
Anyway when I type set in cmd I see the JAVA_HOME variable defined.

0 Karma

linu1988
Champion

try run-> cmd

set JAVA_HOME=C:\Program Files\jdk1.7.0_25

that will do the job

0 Karma

wagnerbianchi
Splunk Employee
Splunk Employee

Did you restarted machine in order to guarantee that Windows will get the new env variable definition?

0 Karma

abpe
Path Finder

I did, still doesn't work.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...