I have a server with Linux Mint OS which has a server-side Maven project that reads some environmental variables.
The environmental variables are declared in /etc/profile.d/my_env_vars.sh with:
export MY_VAR=/opt/my_app
export PATH=$MY_VAR:$PATH
My server side has a function that when I run it from eclipse (installed in my server) it works fine with no errors.
public File convert( byte [] image) throws IOException {
String filePath = System.getenv("MY_VAR");
File imageFile = File.createTempFile("TEMP", "tmp", new File(filePath));
...
return imagenFile;
}
My client-side also is a maven project. It sends a byte[] image to the function above and the server gives it back a result, but I got the NullPointerException error:
java.lang.NullPointerException
java.io.File.<init>(File.java:277)
the second line of my function File imageFile = File.createTempFile("TEMP","temp...
Immediately in my server terminal I verified the environmental variable by echo $MY_VAR and it gives me the correct value (/opt/my_app)
Why does my function work correctly in my server-side but it gives nullPointerException error in the client-side?
I have tried by declaring the environmental variables in other files as ~/.bashrc ~/.profile /etc/bash.bashrc and nothing works. I read in other post to try to edit ~/.bash_profile but Linux Mint doesn't have that file.
I really appreciate any advice.