I need to check whether java installed or not through shell script on Linux.
If not , how can i install the JRE through this script file.
Thanks in advance.
I need to check whether java installed or not through shell script on Linux.
If not , how can i install the JRE through this script file.
Thanks in advance.
Solution 1:
In your terminal type java -version or just javac if it returns something, then you've java installed. Otherwise, there is also the possibility that the path variables do not contain the java path. So use locate jdk or locate java to see if you have the java binary.
Solution 2:
As mentioned above, You should be able to run which java or java -version
Sample Output:
type java || yum install jre
will look for java binary on the path and will try to install jre if java is not present