View Full Version : how does system know Java is not installed?

Sep 10, 2011, 05:32 PM
I'm adjusting the PackageMaker scripts in our installer project so we can detect whether Java is installed or not. If not, our installer can prompt the user to install it. We'd like the user to have Java installed BEFORE they finish installing our product.

When the user upgrades from 10.6.8 to 10.7, the Java files from 10.6.8 are left on the disk. So the 10.7 System Profiler shows Java as being installed. But if I run /usr/bin/java in Terminal, the system will detect this and bring up Software Update.

So, how can my installer bash scripts tell if Java is really installed and enabled or not? Thanks.

Sep 11, 2011, 12:42 AM
What I found out is that during the update from 10.6.8 to 10.7, the update will replace all installed java programs with bogus programs. When you run one of these bogus programs, it says that it can't find the Runtime Environment, and that it will bring up the Software Updater so you can install Java for Lion.

Based on this, I won't be able to use anything about the bogus programs to tell me whether they are from 10.6.8 or from Lion Java. But these bogus programs point to /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents which contains an Info.plist file which contains version numbers for this bogus Java installation.

I can use these version numbers to tell whether the installed Java is 10.6 or 10.7.

Sep 11, 2011, 01:04 AM

I can use these version numbers to tell whether the installed Java is 10.6 or 10.7.I take it that you are unfamiliar with Receipts.

Sep 11, 2011, 11:03 AM
Thanks for this great suggestion! Receipts had slipped my mind. I was too focused on getting version info from the installed files and didn't think about one level up. Thanks again.