[Last Call] Learn how to a build a cloud-first strategyRegister Now

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

Set environment variable from java

Hi,

I need to set system environment variable from java to work cross platform.
just like set in dos, export linux
Any ideas?
0
d2marcelo
Asked:
d2marcelo
  • 3
  • 2
1 Solution
 
objectsCommented:
you can't set environment variables using java
0
 
d2marceloAuthor Commented:
I have a class that will read some paths from a property file and the path has the environment variable on it. How can I make sure java knows what it is.
I try running batch file to set those up before run java but it doesn't work.
0
 
objectsCommented:
you can pass properties on the command line
or you can load the properties file from your application

0
 
d2marceloAuthor Commented:
can you show me how to load the property from the app.  like  path=value
0
 
objectsCommented:
Properties props = new Properties();
InputStream in = new FileInputStream(new File(pathToProperties));
props.load(in);

String value = props.getProperty(path);

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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