Using Python, I want to know whether Java is installed.
Open command prompt and enter “java –version”. If installed version number is displayed. 2. On Windows, Java is usually installed in the directory C:/Program Files/Java.
On Windows 10 you can find out the path by going to Control Panel > Programs > Java. In the panel that shows up, you can find the path as demonstrated in the screenshot below.
Step 1: Open Control Panel and click on Java icon. Step 2: In the Java Control Panel dialog box, click on About button. Step 3: About Java window appears, which shows the Java version.
There is no 100% reliable / portable way to do this, but the following procedure should give you some confidence that Java has been installed and configured properly (on a Linux):
This doesn't guarantee that the user has not done something weird.
Actually, if it was me, I wouldn't bother with this. I'd just try to launch the Java app from Python assuming that the "java" on the user's path was the right one. If there were errors, I'd report them.
You could use the console commands
>>>import os
>>>os.system("java -version")
java version "1.5.0_19"
or see vartec's answer at Running shell command and capturing the output about storing the output
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With