Solved

How do I set up environment variables?

Posted on 1998-07-08
2
175 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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 will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

738 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