MATLAB Answers


Environment variables in javaclasspath.txt

Asked by Xeozim
on 5 Feb 2019
Latest activity Commented on by Yair Altman on 13 Feb 2019
I was whether the functionality for modifying the static path via javaclasspath.txt has any compatibility with environment variables.
I can't post code for security reasons, but I have to change a bunch of paths when I install a new version of the java software (delivered from another team), and I'm trying to eliminate as many of these as possible by referencing environment variables so I can just change one of them when the software is updated.
At the moment I have something like this in javaclasspath.txt
I wasn't sure if the windows syntax
would work, or maybe internal MATLAB syntax
[getenv('MY_ENV_VAR') "subpath\to\file.jar"]
Thanks in advance.


Sign in to comment.




1 Answer

Answer by Yair Altman on 11 Feb 2019
 Accepted Answer

I do not believe that you can use env vars in your javaclasspath.txt file, but as workaround, you can programmatically load the necessary Java classes into the static Java classpath inside your Matlab code, as described in Doing so enables you to programmatically set the path of the loaded classes.


Thanks Yair, love your website by the way!
Glad to hear it - spread the word :-)

Sign in to comment.