<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Setting up the global environment variable for the whole job in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Setting-up-the-global-environment-variable-for-the-whole-job/m-p/2377659#M139470</link>
    <description>&lt;P&gt;Hi, if you really want to set an environnement variable for all the job you can create a routine :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;package routines;&lt;/P&gt;&lt;P&gt;import java.util.Map;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public class MyRoutine {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;@SuppressWarnings("unchecked")&lt;/P&gt;&lt;P&gt;	public static Map&amp;lt;String, String&amp;gt; getModifiableEnvironment() throws Exception&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;Class&amp;lt;?&amp;gt; pe = Class.forName("java.lang.ProcessEnvironment");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;java.lang.reflect.Method getenv = pe.getDeclaredMethod("getenv", String.class);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;getenv.setAccessible(true);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;java.lang.reflect.Field props = pe.getDeclaredField("theCaseInsensitiveEnvironment");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;props.setAccessible(true);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;return (Map&amp;lt;String, String&amp;gt;) props.get(null);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then you can call it and add the env var you want like this :&lt;/P&gt;&lt;P&gt;MyRoutine.getModifiableEnvironment().put("propName", "propValue");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;!! you will see the folowing warning in the console :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WARNING: An illegal reflective access operation has occurred&lt;/P&gt;&lt;P&gt;WARNING: Illegal reflective access by routines.MyRoutine (file:/C:/Users/workspace/LOCAL_PROJECT/poms/code/routines/target/classes/) to method java.lang.ProcessEnvironment.getenv(java.lang.String)&lt;/P&gt;&lt;P&gt;WARNING: Please consider reporting this to the maintainers of routines.MyRoutine&lt;/P&gt;&lt;P&gt;WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations&lt;/P&gt;&lt;P&gt;WARNING: All illegal access operations will be denied in a future release&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;as you can see it's note the best recommended method but it work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if you do System.out.println(System.getenv("propName"));&lt;/P&gt;&lt;P&gt;it will print propValue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;else if you just want to stock a key value use tSetglobalVar component.&lt;/P&gt;</description>
    <pubDate>Thu, 20 Jan 2022 08:48:17 GMT</pubDate>
    <dc:creator>gjeremy1617088143</dc:creator>
    <dc:date>2022-01-20T08:48:17Z</dc:date>
    <item>
      <title>Setting up the global environment variable for the whole job</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Setting-up-the-global-environment-variable-for-the-whole-job/m-p/2377658#M139469</link>
      <description>&lt;P&gt;I am currently trying to create a nee job using Talend Studio. This job requires me to set system environment variable for the whole job, instead of set it per component. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My job is: &lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000N2UIGAA3.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/153605iA12A864412AED19E/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000N2UIGAA3.png" alt="0695b00000N2UIGAA3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So as shown in image below, i managed to set the environment variable in tSystem, but how do i make it so that the environment variable is able to be used for the whole job instead of only one single component in TOS? &lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 23:17:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Setting-up-the-global-environment-variable-for-the-whole-job/m-p/2377658#M139469</guid>
      <dc:creator>WSyahirah21</dc:creator>
      <dc:date>2024-11-15T23:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: Setting up the global environment variable for the whole job</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Setting-up-the-global-environment-variable-for-the-whole-job/m-p/2377659#M139470</link>
      <description>&lt;P&gt;Hi, if you really want to set an environnement variable for all the job you can create a routine :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;package routines;&lt;/P&gt;&lt;P&gt;import java.util.Map;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public class MyRoutine {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;@SuppressWarnings("unchecked")&lt;/P&gt;&lt;P&gt;	public static Map&amp;lt;String, String&amp;gt; getModifiableEnvironment() throws Exception&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;Class&amp;lt;?&amp;gt; pe = Class.forName("java.lang.ProcessEnvironment");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;java.lang.reflect.Method getenv = pe.getDeclaredMethod("getenv", String.class);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;getenv.setAccessible(true);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;java.lang.reflect.Field props = pe.getDeclaredField("theCaseInsensitiveEnvironment");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;props.setAccessible(true);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;return (Map&amp;lt;String, String&amp;gt;) props.get(null);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then you can call it and add the env var you want like this :&lt;/P&gt;&lt;P&gt;MyRoutine.getModifiableEnvironment().put("propName", "propValue");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;!! you will see the folowing warning in the console :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WARNING: An illegal reflective access operation has occurred&lt;/P&gt;&lt;P&gt;WARNING: Illegal reflective access by routines.MyRoutine (file:/C:/Users/workspace/LOCAL_PROJECT/poms/code/routines/target/classes/) to method java.lang.ProcessEnvironment.getenv(java.lang.String)&lt;/P&gt;&lt;P&gt;WARNING: Please consider reporting this to the maintainers of routines.MyRoutine&lt;/P&gt;&lt;P&gt;WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations&lt;/P&gt;&lt;P&gt;WARNING: All illegal access operations will be denied in a future release&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;as you can see it's note the best recommended method but it work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if you do System.out.println(System.getenv("propName"));&lt;/P&gt;&lt;P&gt;it will print propValue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;else if you just want to stock a key value use tSetglobalVar component.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jan 2022 08:48:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Setting-up-the-global-environment-variable-for-the-whole-job/m-p/2377659#M139470</guid>
      <dc:creator>gjeremy1617088143</dc:creator>
      <dc:date>2022-01-20T08:48:17Z</dc:date>
    </item>
  </channel>
</rss>

