Solved

How do I set up environment variables?

Posted on 1998-07-08
2
174 Views
Last Modified: 2010-03-30
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
Comment
Question by:Chandelle
2 Comments
 
LVL 1

Accepted Solution

by:
VincentT earned 200 total points
ID: 1225424
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
 
LVL 5

Expert Comment

by:fontaine
ID: 1225425
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Weekend adv creator 3 54
jsp login check 12 43
How to determine if a string is a valid SHA value 7 36
java example issue 5 26
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question