Pramit
January 10, 2012, 4:05am
1
Hi,
I'm trying to test one unix shell script in dev environment. But I'm not sure how to pass the environment in my java program calling code. I'm trying to use -DconsumerEnv="DEV" but unfortunately I get 'null' while trying to print the value from java class.
System.out.println("Environment: "+ System.getProperty("consumerEnv"));
This is the code I'm using to call the java program from my unix script:
java -Xms64m -Xmx256m -Djava.library.path=$MY_CLASSPATH -cp $MY_CLASSPATH <<class-name>> -DconsumerEnv=$consumerEnv
I have verified that the value of $consumerEnv is coming as DEV.
Can anyone please help?
Thanks in advance.
try this
java -Xms64m -Xmx256m -Djava.library.path=$MY_CLASSPATH -cp $MY_CLASSPATH <<class-name>> -DconsumerEnv="$consumerEnv"
Rksiva
January 10, 2012, 4:17am
3
Try this,
java -Xms64m -Xmx256m -Djava.library.path="$MY_CLASSPATH" -cp "$MY_CLASSPATH" <<class-name>> -DconsumerEnv="$consumerEnv"
try this inside the script which may solve ur problem :
DconsumerEnv="$consumerEnv"
export $DconsumerEnv
java -Xms64m -Xmx256m -Djava.library.path="$MY_CLASSPATH" -cp "$MY_CLASSPATH" <<class-name
Pramit
January 11, 2012, 3:54am
5
Still no luck
I tried this:
java -Xms64m -Xmx256m -Djava.library.path=$MY_CLASSPATH -cp $MY_CLASSPATH <class name> -DconsumerEnv="$consumerEnv"
export $DconsumerEnv
---------- Post updated 01-11-12 at 02:54 AM ---------- Previous update was 01-10-12 at 04:40 AM ----------
I found the resolution:
swapping <<class-name>> & -DconsumerEnv will work.
See the corrected code below:
java -Xms64m -Xmx256m -Djava.library.path="$MY_CLASSPATH" -cp "$MY_CLASSPATH" -DconsumerEnv="$consumerEnv" <<class-name>>
Thanks everyone for helping!!!!!...