Solved

How do I set up environment variables?

Posted on 1998-07-08
2
176 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

624 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