Showing posts with label osx. Show all posts
Showing posts with label osx. Show all posts

Sunday, 22 January 2012

Setting JAVA_HOME on MAC OS X


There are two parts to this problem - figuring out where Java is installed in your system and then setting up the environment variable in a reliable way so its always available.

There is a command you can use to find the actual path of Java on your system:

/usr/libexec/java_home

on my system this gives:

/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

on your system it may be different and of course it will change with every release of Java installed.

Apple recommends in this article that instead of referencing this path directly you point your Java_Home environment variable to this symbolic link instead:

/Library/Java/Home

This link actually points to a chain of links which ultimately end up in the /System/Library/Java... path above.

So that's step one sorted, what about step two: setting up the environment variable?

A discussion here seems to favour setting the variable in /etc/launchd.conf, the reasoning for this is made clear in the discussion. I took their word for it, and it worked for me, if your happy to do the same go ahead and edit the following file:

/etc/launchd.conf

this file may not exist already on your system, in which case editing it will cause it to be created. 

Add this line:

setenv JAVA_HOME /Library/Java/Home

That should do it, but you'll need to restart your system for the change to take effect.

After the restart open up a terminal and enter the following command to see a list of the currently defined environment variables:

export

you should see JAVA_HOME listed and the value should be /Library/Java/Home.

if you want to refer to the environment variable in scripts or from the terminal you need to prepend $ to the environment variable, for example:

echo $JAVA_HOME

will display the value of the variable, while the following will take you to the Java directory:

cd $JAVA_HOME

Well that's two hours of my life i'm not getting back - I hope this post saved you a bit of yours!

Thursday, 19 January 2012

How To Verify a SHA1 Checksum on OS X

Its so simple you'd be silly not to...

Download the file to somewhere close to hand such as the Desktop or Downloads folder

Open a Terminal from Applications->Utilities->Terminal.app

In the terminal enter the path to the sha1 command:

/usr/bin/openssl sha1

Enter an extra space at the end of the command - Don't press Enter yet!

now drag the downloaded file from wherever you stored it into the terminal window and OS X will kindly enter the path to the file for you - nice :)

Now press enter and the sha1 program will generate the sha1 checksum.

Compare the output from sha1 with the checksum on the download site - as long as they match you can be confident the file is authentic. If not send it to the trashcan!