Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This won't work, and here's why. Environment variables are inherited from the parent process. A child can't control a parent's environment. Here's what's happening in your setup:</p> <pre><code> bash -&gt; java -&gt; unset | | | parent child grand-child | | | unaffected unaffected affected </code></pre> <p>So in actuality your command IS working, however it's not having the effect you want it to. Sadly java won't be able to change the parent's environment.</p> <p>Your java program <em>can</em> modify environment variables of its own, and any children spawned by java will inherit those variables. So you could potentially have java launch a bash shell for you, and then use that bash shell interactively, but that seems like a lot of overhead.</p> <p>See this post for how to set java's environment variables:<br> <a href="https://stackoverflow.com/questions/318239/how-do-i-set-environment-variables-from-java">How do I set environment variables from Java?</a></p> <p>If you're willing to sidestep the whole java problem, what most people do in this situation is source a special file. For example, create a file called "no-x.sh" that looks like this:</p> <pre><code># Unset the display variable unset DISPLAY </code></pre> <p>And then from your current (interactive) shell, source the file like this:</p> <pre><code>$&gt; source no-x.sh </code></pre> <p>and now your main bash shell has had its environment changed. Note that this is a HACK (or for all of you bash zealots out there -- a feature) and you should never expect to duplicate this functionality with anything else (like java).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload