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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] How to set the Config folder path at runtime?

Hi Shong,
While exporting the job, the source code containing the hard coded value of config folder path. How to pass the path value as a command line argument?
Code Snippet:
-----------------
Instead of this one:
java.io.InputStream inContext = Context.class.getClassLoader()
.getResourceAsStream(
"config/context_0_1/contexts/" + contextStr
+ ".properties");
i need the following oprtions:
java.io.InputStream inContext = Context.class.getClassLoader()
.getResourceAsStream(
contextStr+ ".properties");
or
java.io.InputStream inContext = Context.class.getClassLoader()
.getResourceAsStream(
configpath + contextStr
+ ".properties");

Thanks in advance...
Labels (3)
1 Solution

Accepted Solutions
alevy
Specialist
Specialist

In the screenprint you can see that the Default values of the context have been overridden in running the job by those from c:\program files\vars.txt. The actual location of vars.txt is passed to the job from the command line.

View solution in original post

9 Replies
Anonymous
Not applicable
Author

Hi,
You can set up this path value as a context, ie. context.path.
When you execute the jar file, you can directly override a context variable from a commandline using --context-param path=mypath
Anonymous
Not applicable
Author

Hi Shong,
I thought that you didn't understand my scenario. But i got your point. My scenario is to use the context variables in Context file. But path of the context file path should be passed as command line argument. It contains at the executable batch/shell file level.
instead of this one:
java -Xms256M -Xmx1024M -cp classpath.jar: config.sqljdbc_0_1.SQLJDBC --context=Default $*
i need the following one
java -Xms256M -Xmx1024M -cp classpath.jar: config.sqljdbc_0_1.SQLJDBC --context=<filepath>/Default $*
Because the source code cointains the hard coded context path as mentioned in the previous thread.
please see the screen shot below.
Anonymous
Not applicable
Author

Hi
i need the following one
java -Xms256M -Xmx1024M -cp classpath.jar: config.sqljdbc_0_1.SQLJDBC --context=<filepath>/Default $*

It is impossible, the path of .properties is fixed now. You can report a new feature on our bugtracker.
Best regards
Shong
alevy
Specialist
Specialist

If you use tContextLoad or implicit context loading in your jobs rather than the context group values preset within the studio you can specify the location of the file containing your context values at run-time. Within the job, set the location of the file to itself be a context variable and then set that location at run-time e.g.
java -Xms256M -Xmx1024M -cp classpath.jar: config.sqljdbc_0_1.SQLJDBC --context_param contextfile="C:/my context files/contextfileA.txt"
Anonymous
Not applicable
Author

I have used tContextLoad but no luck i can't able to specify the property file i.e still java code containing the hard code of properties path Can u plz send me some screen shots
alevy
Specialist
Specialist

In the screenprint you can see that the Default values of the context have been overridden in running the job by those from c:\program files\vars.txt. The actual location of vars.txt is passed to the job from the command line.
Anonymous
Not applicable
Author

Hey can anyone out here tell me how to pass context variable value to .sh file
I mean I exported my job for UNIX platform and calling the same from my Java code.
It is unable to load Command Line Input...
Plz help.. Its urgent..
Anonymous
Not applicable
Author

Hello alevy,
Thanks for your solutions. It works for me..Problem resolved.