Custom JRE for tentacle

Hi, I am trying to install a tentacle on a machine to deploy Java JARs, but it doesn’t have a JRE “installed” - mainly because there are different (old) versions of the JDK for different applications and thus don’t have a “global” version on our path.

We’re getting this error when we deploy:

“Failed to run java. You must have Java 1.8 or later installed on the target machine, and have the java executable on the path or have the JAVA_HOME environment variable defined”

Is there a way to configure a custom value of JAVA_HOME for just the tentacle or the project, and point this to some JRE8+ unzipped to a specific directory?

I don’t want to set this as a system-wide environment variable otherwise it might interfere with the aforementioned processes.


PS I have toyed with the idea of running the tentacle as a specific user, and setting JAVA_HOME for just that user. But logging into the host as that user to set the variables, or hacking them in via the registry, isn’t possible right now (company policies).

Hi Oliver,

Welcome to the Octopus support community!

Good question! While there isn’t anything built directly into Octopus that would support what you’re trying to do, you could try running some Powershell before the deployment that would set the variable for the session the tentacle is using.

Your idea of running the tentacle as a specified user and setting JAVA_HOME for just that user may be the best/only way forward with this.

Please let me know how you get on!

Thanks Stuart.

I tried modifying my process so the first step was a Powershell script setting JAVA_HOME from a variable:

${JAVA_HOME} = "$jdk_home"

But this has the same problem, I’m guessing because the “process scope” is different for the different steps but could perhaps be syntax.

(I also tried $Env.JAVA_HOME = ... but that blew up.)

Can you recommend the “correct” place for this PS?


Hey @oliver.r

The correct place depends on which step you are using for the java deployment. You may be able to use our Run A Script step and use it on a pre-deploy script.

Hope this helps point you in the right direction!

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.