Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 178
  • Last Modified:

How do I set up environment variables?

I am writing an install program for some software that I developped, but I now realise I need to include some environment variables in my install process for it to work. How is this done, do I set the install program to get the user to state the were these variables are to be located or....what???
0
Chandelle
Asked:
Chandelle
1 Solution
 
VincentTCommented:
Could you be more specific?
Are you talking about operating system environment variables or java system properties?

First case :
On win95, edit you autoexec.bat file and add your environment variables this way
set VARIABLE=value
In Unix(csh, tcsh), use
setenv VARIABLE value

Second case :
You can add a system property to a jvm when launching it.
for example :
java -Dvariable=value ClassToLaunch

In your java program, you can access this variable using the call
String value = System.getProperty("variable");

I hope this aswers the question!
0
 
fontaineCommented:
Tell me if this is what you are expecting. This example reads the PATH environment
variable of a Windows machine:

- command line: java -DPATH="%PATH%" Environment

- code:

public class Environment {

    public static void main(String args[]) {
        String path = System.getProperty("PATH");
        System.out.println(path);
        return;
    }
}


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now