Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Below is the link which explains on how to set environment variable in a Windows machine <strong>manually</strong>:</p> <p><a href="http://www3.ntu.edu.sg/home/ehchua/programming/howto/Environment_Variables.html" rel="nofollow">http://www3.ntu.edu.sg/home/ehchua/programming/howto/Environment_Variables.html</a></p> <p>A piece taken from above link (must read the link completely, its very rich in knowledge):</p> <hr> <blockquote> <p><strong>Display Variables and their Values</strong></p> </blockquote> <p>To list all the variables and their values, start a CMD shell (Click "Start" button ⇒ Run ⇒ Enter "cmd") and issue the command "set". To display a particular variable, use command "set varname". For examples,</p> <pre><code>// Display all the variables (in NAME=VALUE pairs) prompt&gt; set COMPUTERNAME=xxxxxxx OS=xxxxxxx PATH=xxxxxxx ....... // Display a particular variable prompt&gt; set COMPUTERNAME COMPUTERNAME=xxxxxx // OR use echo command with variable enclosed within a pair of '%'s prompt&gt; echo %COMPUTERNAME% COMPUTERNAME=xxxxxx </code></pre> <p>Try issuing a set command on your system, and study the environment variables listed. Pay particular attention to the variable called PATH.</p> <blockquote> <p><strong>Set/Change/Unset a Variable</strong></p> </blockquote> <p>To set (or change) a variable, use command "set varname=value". There shall be no spaces before and after the '=' sign. To unset an environment variable, use "set varname=", i.e., set it to an empty string.</p> <pre><code>prompt&gt; set varname prompt&gt; set varname=value prompt&gt; set varname= prompt&gt; set </code></pre> <blockquote> <p><strong>Display the value of the variable</strong></p> </blockquote> <p>Set or change the value of the variable (Note: no space before and after '=') Delete the variable by setting to empty string (Note: nothing after '=') Display ALL the environment variables. For examples,</p> <pre><code>// Set an environment variable prompt&gt; set MY_VAR=hello // Display prompt&gt; set MY_VAR MY_VAR=hello // Unset an environment variable prompt&gt; set MY_VAR= // Display prompt&gt; set MY_VAR Environment variable MY_VAR not defined </code></pre> <p>A variable set via the "set" command under CMD is a local variable, available to the current CMD session only.</p> <hr> <p>If you want to set the same using Java code, below is one example:</p> <pre><code>public static void main(String[] args) throws IOException { ProcessBuilder pb = new ProcessBuilder("CMD", "/C", "SET"); Map&lt;String, String&gt; env = pb.environment(); env.put("MYVAR", "myValue"); Process p = pb.start(); InputStreamReader isr = new InputStreamReader(p.getInputStream()); char[] buf = new char[1024]; while (!isr.ready()) { ; } while (isr.read(buf) != -1) { System.out.println(buf); } } </code></pre> <p>If you want to pass some value to your program, you could also do that in command line:</p> <pre><code>java -DMyVar=varValue &lt;main program&gt; </code></pre> <p>This value could be read as:</p> <pre><code>String myVar= System.getProperty("MyVar"); </code></pre>
    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.
 

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