bash - my server-side shows nullPointerException when client-side runs java -


this question has answer here:

i have server linux mint os has server-side maven project reads environmental variables.

the environmental variables 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 function when run eclipse (installed in server) works fine 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 maven project. sends byte[] image function above , server gives result, got nullpointerexception error:

java.lang.nullpointerexception java.io.file.<init>(file.java:277) second line of function file imagefile = file.createtempfile("temp","temp... 

immediately in server terminal verified environmental variable echo $my_var , gives me correct value (/opt/my_app)

why function work correctly in server-side gives nullpointerexception error in client-side?

i have tried declaring environmental variables in other files ~/.bashrc ~/.profile /etc/bash.bashrc , nothing works. read in other post try edit ~/.bash_profile linux mint doesn't have file.

i appreciate advice.

on client, nullpointerexception thrown because environment variable not set correctly , null passed constructor of file.

put my_var in ~/.profile , notice file loaded once when login. therefore, after setting new environment variable, make sure log out , in. if file doesn't exist, create it.

you can test it's set using:

$ env | grep my_var my_var=value 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -