Friday, April 08, 2016

How to force java path in subscript (nested script call)

If you use a script that runs another script which starts a java virtual machine, you should need to specify which java command you want to use from the first script. Consider the following example :  ---> --> java command

I can modify but not which calls java command. But I need a specify version a java.

So, I tried to solve this problem with :

  • linux 'source' command ... BAD!!!
  • linux 'alias' command... BAD!!!
But, I finally got a working solution by redefining a  'java' function before calling GOT IT! When calls 'java', it invokes my function. Like this :

java() {
    /specificpath/jdk/bin/java "$@"
export -f java
sh ./