How do you append environment variables to a java clojure cli?

384 Views Asked by At

I have files which are created via clojure

frontendapp.jar
backendapp.jar 

and take an environment variable, APP_PORT

What I want to understand is how do I pass variables to the jar files so that they run with the variable APP_PORT?

My assumption is something like this

java -jar frontenapp.jar APP_PORT=8080 

Am I correct in my assumption?

Apologies if the question is bad, it's my first time deploying a clojure application

1

There are 1 best solutions below

0
jas On

Assuming a unixy shell like bash, you can do

$ APP_PORT=8080 java -jar frontendapp.jar

or perhaps more commonly:

$ export APP_PORT=8080
$ java -jar frontendapp.jar

In the first case, APP_PORT will only be set in the environment given to the java process. In the second case, with export, the variable will be set in the environments of all processes subsequently started from that shell.