Solved

How do I set up environment variables?

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How Complex Is This Java Course ? 9 63
pairstar challenge 2 42
java  and programming certification ? 4 65
Java Loop 6 25
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now