Can’t run java in bash script : bioinformatics

I was trying to re-use one of my old scripts for trimmomatic but I was getting error “java: command not found”.

I realised that it will work if the java command is first. It stops if there is anything above it, e.g

This works:

#!/bin/bash
java --version
PATH=/media/msz/Arabidopsis_project/scripts

$ ./test.sh 
openjdk 11.0.11 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.18.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.18.04, mixed mode, sharing)

This won’t :

#!/bin/bash
PATH=/media/msz/Arabidopsis_project/scripts
java --version

$ ./test.sh 
./test.sh: line 3: java: command not found

Anyone have any idea what is going on?

Thanks for your help!

Read more here: Source link