Installing Homebrew in Mac OS X 10.9 (Mavericks)

Installing Homebrew in previous OS X versions was holding a dependency on having Xcode pre-installed which is a substantial dependency (in terms of volume size) especially considering that you might not even be using this IDE as was always my case.

Not any more.

Apparently the Xcode part that is needed by Homebrew and other 3rd party tools, dubbed Command Line Tool in the net, has been extracted from Xcode and is being made available via the simple Terminal command in Mac OS X 10.9:

xcode-select --install

that pops up a pane to confirm auto-download of the tool.

From that point onwards Homebrew installation can continue with the ruby script as it was always the case. After installation completes ‘brew doctor’ can assure you that all is good and you can start amassing Cellars for the brewing process.

How to install Oracle Database on Mac OS (Any Version)

25 Apr 2014 Update: This guide has been originally written 2 years ago describing Oracle 11gR2 DB installation. Now it has been revised for the latest Oracle 12cR1 DB.

Introduction

Installing Oracle DB on any Mac OS version is not an easy task. Official support was dropped from 10g onwards around the early days of Mac OS X and since then there has been endless questions online of how to go about later versions like Leopard (10.5), Snow Leopard (10.6), Lion (10.7), Mountain Lion (10.8) or Mavericks (10.9).

I have yet to find a consistent resource online of how to natively install the database and I have also tried my hands on binaries compilation and package transfers along all the previous versions with various, inconsistent results. I have to admit that this long-winded process gets too complicated for my taste and patience.

The people at Oracle have acknowledged this problem and have provided a neat solution abstracting all the complicated noise, packing up all the required tools and needed configurations in a single image file readily to be hosted as a VM in VirtualBox.

This is old news and although VirtualBox is well documented I haven’t again found a single resource that is describing the process from top to bottom for my setup which is a Macbook Pro using WiFi therefore this detailed tutorial.

*General Note: As the creators suggest Oracle XE should be used for testing purposes only. Also the majority of passwords on the VM have been setup by default to oracle and should be changed for obvious security reasons.

Step 1: Getting VirtualBox

This is as simple as any other installation on a Mac. All we have to do is grab our x86 version (assuming an Intel CPU) for Mac from the official download page.

25 Apr 2014 Update: Currently VirtualBox is @ version 4.3.10 and doesn’t seem any different.

Step 2: Getting the VM file

This is the download page and the download instructions are clear. The ova VM file is big ~4G so better start the download process on a browser that has an integrated download manager like Firefox if you have a slow connection or are frequently experiencing dropped connections.

Apparently this VM has been initially created for a developer’s workshop but gets frequently updated with the latest and greatest of Oracle Client, Oracle SQL Developer and other tools. Various walkthroughs and other interesting tutorials are loaded-up on the VM awaiting to be discovered but all we care about is the Oracle 11gR2 DB which will be by default up and running when the VM is loaded into memory.

25 Apr 2014 Update: This is still the go-to place to get the OVA file. The difference is that the size of the file now spans ~ 5.22GB and has been prefixed with “OTN_” in the name. And of course it sports the latest Oracle 12cR1 DB along with the latest SQL Developer 4.

Step 3: Installing the Guest VM

Our host OS is apparently Mac OS and the guest VM is Oracle Linux 5 which is a branch off Red Hat Linux.

From the VirtualBox Menu we select File > Import Appliance

Then we make it point to the VM file we’ve just downloaded:

Import Virtual Applicance-2

VirtualBox-1

25 Apr 2014 Update: In the picture above as mentioned in the previous section the name should be “OTN_Developer_Day_VM.ova” and the size ~ 5.22GB.

25Apr14-1-importOvaToVirtualBox

Click here for an older version of the picture above installing version 11gR2

 

After the import gets completed we are ready to start the VM:

25Apr14-2-importedIntoVirtualBox

Click here for an older version of the picture above installing version 11gR2

 

Step 4: Starting the VM

Starting up the VM is as easy as inserting oracle/oracle when we are prompted for username/password:

25Apr14-3-loginScreen

Click here for an older version of the picture above installing version 11gR2

When the OS boots up we are ready to go:

25Apr14-4-loggedIn

Click here for an older version of the picture above installing version 11gR2

Step 5a: Making Oracle DB visible  – Internet Connectivity

On the top right of the VM there should be an icon denoting Internet connectivity on the VM. If by default it is disabled it might need a kick to connect and as long as your Host OS has Internet connectivity it will connect without issues:

25Apr14-5-disconnectedByDefault                     25Apr14-6-connected

Step 5b: Making Oracle DB visible – Firewall

This is a tricky step that we didn’t need to perform 2 years ago on that flavour of OracleOS that was hosting 11gR2.

Basically the OracleOS Firewall is activated by default. So we have two solutions:

Solution 1 – Switch-off the OracleOS Firewall altogether

The Firewall is accessible via System(top left)>Administration>Firewall

25Apr14-7-accessFirewall

 

On the Firewall Configuration panel click on the Disable button and then the Firewall disabled should look like this:

25Apr14-8-FirewallDisabled

Solution 2 – Allow port 1521 in Firewall to be accessible remotely

25Apr14-9-FirewallPort1521Trusted

Step 5c: Making Oracle DB visible – VirtualBox PortForwarding

By default VirtualBox > Devices > Network Adapters is attached to an internal NAT that should hopefully give you access to Internet.

Oracle Developer Days - Network

My setup is a MacBook Pro that is getting Internet via WiFi therefore I’ve tried to get the Bridged Adapter via WiFi to work that is initiating a more direct connection between the Host and Guest VM but to no avail. I’ve tried several things suggested out there such as reducting the MTU to 1496 or downgrading to IPv4 but without luck.

The solution lies in the Port Forwarding option under the Network Adapters picture above:

VirtualBox VM

Here we define external requests coming from localhost (127.0.0.1) to the standard Oracle communication default 1521 TCP port to be forwarded to our Oracle VM with IP address 10.0.2.15 on the same port. The IP of the Oracle VM can be found by issuing ipconfig command on the terminal (3rd line, inet addr):

25Apr14-13-findTheIPAddr

Click here for an older version of the picture above installing version 11gR2

Step 6a: Testing external connectivity – via Telnet

From the Host OS (Mac OS X Mavericks) we can test that we can connect to localhost at port 1521:

25Apr14-15-telnet

 

Step 6b: Testing external connectivity – via IDE

Also by using IntelliJ (13.1 in this example) datasource capabilities we can successfully connect to the Oracle’s Sample HR database (username: hr, password: oracle):

25Apr14-11-HRDBFromIntelliJ

Click here for an older version of the picture above installing version 11gR2

25 Apr 2014 Update: Note the correct connection jdbc url:

jdbc:oracle:thin:@//127.0.0.1:1521/PDB1

In prior version 11gR2 it used to be (but this does not work anymore):

jdbc:oracle:thin:@//127.0.0.1:1521:orcl

Step 6c: Testing external connectivity – via SQL Developer

SQL Developer 4 @ Mac OS X Mavericks:

25Apr14-12-HRDBFromSQLDeveloperIMac

Click here for an older version of the picture above installing version 11gR2 sporting SQL Developer 3 at the time

Conclusion

That’s a quick, clean and bulletproof way of having the most recent Oracle DB running on a Guest VM not only on Mac OS but on any OS.

PS. If you have a Synology NAS like I do, you might want to check out my detailed tutorial on how to host the VirtualBox VMs on the NAS and connect to it via the supported iSCSI protocol by VirtualBox clients installed on any home/work computer.

Install Java 6,7,8 on Mac OS X

Here’s a quick guide to have Java versions 6,7,8 installed on Mac OS X above and beyond.

Java 6

Java 6 is the last supported version provided by Apple. Therefore we’ll follow the Apple way to install the JDK although Java 1.6 can be branched out from Oracle or the OpenJDK project.

Successful installation will place Java 6 under /Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/. Following that you can mark JAVA_HOME or point your IDE towards /Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Home/. Also to browse the JDK under an IDE point your editor to the JDK sources found in /Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Home/src.jar

Java 7

We need to go out in the wild to get JDK 7 installed on Mac OS X since mother-Apple doesn’t support it. We can download it either from Oracle or OpenJDK:

Successful installation will place Java 7 under /Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/. Following that you can mark JAVA_HOME or point your IDE towards /Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home/. Also to browse the JDK under an IDE point your editor to the JDK sources found in /Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home/src.jar

Java 8

We can get a copy of the latest snapshot of JDK 8 to play around with the lambda expressions (natively supported on IntelliJ IDEA) if you haven’t tried already closures in Groovy, Scala or just Predicates/Functions in Google Guava from this download resource

Successful installation will place Java 8 under /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/. Following that you can mark JAVA_HOME or point your IDE towards /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/. Also to browse the JDK under an IDE point your editor to the JDK sources found in /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/src.jar

Installing Java 7 on Mac OS X Lion

Installing Java on Mac OS X used to be a breeze. Once upon a time it was part of the regular Apple update but at some point in midst Java 6 it stopped being supported and now if you want Java 7 you would need to build the jdk first to get the precious binaries.

If you are after only the binaries I found this place where they are made available. Completing the installation is a matter of drag-and-drop and finally jdk 7 will reside in /Library/Java/JavaVirtualMachines/1.7.0.jdk/.

Don’t forget to create/update environment variables or point to that location from your Eclipse, IntelliJ or other IDE. As far as I have checked, Eclipse Indigo 3.7.1 is supporting Java 7 on the fly syntax checker as part of its updated JDT. Older versions of Indigo wouldn’t recognise ie. project coin changes.

Useful Eclipse Shortcuts Mac OS X

  • Cmd + Shift + O: Removes all unused imports.
  • Cmd + Shift + F: Code beautifier.
  • Cmd + Alt + DOWN: Duplicates the current line.
  • Ctrl + Shift + UP: Wherever the cursor, while keep hitting UP, the next current bigger entity is getting selected i.e. current word > current phrase > current statement > current line > current method body > current method > current class > current file.
  • Ctrl + H: Search tab.
  • Ctrl + 1: Applying all suggested fixes.
  • Cmd + T: Type hierarchy for the current cursor item. Repeat the shortcut a second time to see superclasses hierarchy.
  • Cmd + Shift + R: Resources tab that dynamically retrieves resources, mostly you’ll need it for classes, interfaces, enums and config files to bring up.
  • Cmd + Shift + T: Same as its cousine Cmd + Shift + R, but dynamically autocompletes only types (classes, interfaces) in the search tab.
  • Cmd + D: Delete current line.
  • Cmd + M: Minimize/Maximize current tab.
  • Cmd + N: New tab in the selected item in the Package Explorer.
  • Cmd + O: Quick Outline. Similar to the Outline view.
  • F3: Drilling into current cursor location.
  • Cmd + Left Mouse Click: Open Implementation option appears that polymorphically gives you all options. I.e. whenever F3 gets to to an interface method, Cmd+Left Click presents you with all the override options instead which is 99% of the cases where you want to navigate.
  • Ctrl + Alt + H: Call Hierarchy. Summarises all places where this method has been called.