Hi All,

I am trying to extract a full path from a certain environment variable.

What if there is an environment vaiable called CATALINA_HOME
how can I extract a full path of the environment from java?

I am trying to use a filewriter object to create a file,

for example,

FileWriter writer = new FileWriter("%CATALINA_HOME%\\test.csv");
writer.append("test");
writer.close();

but it is not recognizing the environment variable.


Thank you.

Recommended Answers

All 2 Replies

Of course it isn't.
You need to first get the value of that variable from the environment yourself, and then use that to construct the actual path to write to.

Perhaps

String variable = System.getenv("MY_ENV_VARIABLE");

might be useful.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.