0

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.

1

2 Answers 2

2

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:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

type java || yum install jre

will look for java binary on the path and will try to install jre if java is not present

2 Comments

yum install jre looks downlods jre from the internet, instead it should install the one that is bundled with the package.
Of course, jre can be installed via a tarball, instead of using rpms and yum repos. Replace yum install jre by your preferred jre deploy method

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.