I am trying to set an environment variable using a java code. When i run this java code from the bash, I want to echo the environment variable that i set in the java program. How can this be done

1 Answer 1


If you're talking of something like this:

$ java Foo
$ echo ${var_set_by_foo}

This cannot be done. A process cannot affect another's environment, and a Java program is perforce run as a separate process from your shell.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .