1

I am working on an enterprise system where I can't control my system Path environment variable, and the system path points to a version of Java that is currently broken. I have another version of Java installed, and I would like to use that to run the Ammonite shell. Is this possible?

Liam Bohl
  • 21
  • 3
  • 2
    I guess you just need to change the `JAVA_HOME` and / or `PATH` env variables. – Luis Miguel Mejía Suárez Aug 19 '21 at 15:41
  • In **UNIX** systems you can change the environment of the current shell or even just of the current command without affecting the system environment. Not sure if you can do that on **Windows** _(never used that OS for other than playing, but I hope this helps you find a solution)_. If it is possible but you can't even change it for a current terminal / command, then you can't do anything AFAIK. – Luis Miguel Mejía Suárez Aug 19 '21 at 15:59
  • 1
    @LuisMiguelMejíaSuárez Great point. Editing the Path variable for just the current shell session was the solution I landed on. – Liam Bohl Aug 19 '21 at 16:30

1 Answers1

1

My hacky solution was to rename ammonite from amm.bat to amm-default.bat and create a new batch file called amm.bat that just adds my desired jre to the front of the session Path:

@echo off
set Path=C:\Users\bohlli\.jdks\corretto-1.8.0_292\bin;%Path%
amm_default.bat

I tried changing the path in the ammonite batch script itself, but every time I tried, something broke.

Liam Bohl
  • 21
  • 3