Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
peterm1
Contributor
Contributor

Getting Environment Variable

I'm using Talend ESB Enterprise and am running a tJava that needs to look at an Environment variable. When I run it local on my machine I get the value no problem. When I push it to Karaf the value is null. I wrote some test code to make sure the value is set correctly on the bus and it is but whenever I run a job on Karaf I get null.
Labels (3)
6 Replies
Anonymous
Not applicable

Hi,
how do you read the env. variable? could you post the code snipet? (+ platform, version,..)
Gabriel
peterm1
Contributor
Contributor
Author

I'm trying to do just a simple getEnv. Do I need to do something different because it's using maven to run the job?
context.new1 = System.getenv("TEST");
Anonymous
Not applicable

well, I expected a little bit more information. to help you.
- how do you set the env. variable? as a jvm parameter? as an env. system variable?
- what platform do you run on? did you export the env. variable? how do you start the esb runtime (bin/trun, bin/start, as a service?)?
have fun
Gabriel
peterm1
Contributor
Contributor
Author

I'm running the ESB on Ubuntu with JAVA 1.6 u32 and I am exporting the environment variable at the OS level. I've written a small test harness using java code to pull the variable and I get it through there but not the BUS. I start from bin/trun and no I am not pulling it in as a JVM paramater I should not half to since it is a System level variable System.getenv should work in that case.
So just to be clear and give you more info below is the set of the OS variable
export TEST=MYTESTVAR
JAVA code in talend job
context.new1 = System.getenv("TEST");
Anonymous
Not applicable

Hi,
indeed seems this way it doesn't work under linux
If you have an enterprise edition, you may fill a support request if that's a blocker, (well, at the end of the day you will need env variables in production deployment ) until then let's find a workaround..
Gabriel
Anonymous
Not applicable

Hi,
so - it works for me. You have to set env variables into ~/.bashrc (so it will be available for new forks too)
test=123
export test

you can reload envs as source ~/.bashrc
hope it helps
Gabriel