Over a million developers have joined DZone.

Setting Up A MacBook Pro for Java Development

Read this wonderful primer for developers switching to the "dark" side and acquiring a MacBook Pro. It includes some tips for the German/Swiss keyboard.

· Java Zone

Learn more about the advantages of moving from a monolithic to microservices architecture.  Brought to you in partnership with IBM.

Well, I went to the “dark” side and acquired a MacBook Pro to use it for development when I am not at my PC. This post should be viewed as an enhanced bookmark where I list the tools I had to install so that the MacBook will fulfil its purpose, namely to be used for Java and later for Javascript development.

I need to mention that until now I’ve been a user of Windows (XP/7) and Linux (Ubuntu/Mint/Cent OS). At the time of this writing, my MacBook Pro runs on OS X Yosemite Version 10.10.5


So first things first. Install a Java Development Kit (JDK), which is a software development environment used for developing Java applications and applets. It includes the Java Runtime Environment (JRE), an interpreter/loader (java), a compiler (javac), an archiver (jar), a documentation generator (javadoc) and other tools needed in Java development.

Download the Mac OS X x64 .dmg files version

You can find out where the JDK is installed, by executing the /usr/libexec/java_home -v 1.7 , on the terminal command:

Adrians-MacBook-Pro:ama ama$ /usr/libexec/java_home -v 1.8
Adrians-MacBook-Pro:ama ama$ /usr/libexec/java_home -v 1.7
Adrians-MacBook-Pro:ama ama$

You will need to know this when setting up a project in IntelliJ for example.


JAVA_HOME is just a convention, usually used by Tomcat, other Java EE app servers and build tools such as Maven to find where Java lives.

In Mac OSX 10.5 or later, Apple recommends to set the $JAVA_HOME variable to /usr/libexec/java_home, just export $JAVA_HOME in file ~/. bash_profile or ~/.profile

$ vim .bash_profile 

export JAVA_HOME=$(/usr/libexec/java_home)

$ source .bash_profile

$ echo $JAVA_HOME


Once you have set up the JAVA_HOME environment variable as specified above, go to the Apache Maven Downloads website, download the .tar.gz or .zip archive and unpack it in a folder of your choice – I put it under the /opt directory:

tar xzvf apache-maven-3.3.3-bin.tar.gz

It is also recommended to create a symbolic link to the Maven installation, so that when let’s say you update your Maven version,  you’ll only have to change the symbolic link target:

ln -s /opt/apache-maven-3.3.3 /opt/maven

Then set Maven in the environment variables

vim ~/.bash_profile
export M2_HOME=/path/to/maven
export M2=$M2_HOME/bin
export PATH=$M2:$PATH

Close the terminal and open a new one. When you try now to get the maven versioning you should get something like the following:

ama$ mvn -version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T13:57:37+02:00)
Maven home: /opt/maven
Java version: 1.8.0_65, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.5", arch: "x86_64", family: "mac"

An alternative is to use Homebrew and execute the following command:

brew install maven


Open a terminal window and type the following command for example:

$ git --version

At the next moment you will be asekd to install Xcode. This is the a complete developer toolset for building apps that run on Apple TV, Apple Watch, iPhone, iPad, and Mac. It includes the Xcode IDE, simulators, and all the required tools and frameworks to build apps for iOS, watchOS, tvOS, and OS X (it also contains GNU Compiler Collection-gcc).

You can do the above, but if you do not want everything from that package you can install Homebrew (“Homebrew installs the stuff you need that Apple didn’t.”) and run the following commands:

brew install gcc
brew install git

Either way once Git is installed the initial command git –version will bring the installed version:

$ git --version
git version 2.4.9 (Apple Git-60)

If you are working with Github, I recommend you also install the Github Desktop


In the mean time IntelliJ has become my favorite IDE, mainly because you have almost the same feature support when doing front-end development. To install it, go to the download page and follow the installation instructions:


  • Download the idea-15.dmg OS X Disk Image file.
  • Mount it as another disk in your system.
  • Copy IntelliJ IDEA to your Applications folder



Node.js® is a JavaScript runtime built on Chrome’s V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js’ package ecosystem, npm, is the largest ecosystem of open source libraries in the world. Recently is a must have tool if you need to do fancier stuff on your front-end part of your application.

Go to https://nodejs.org/ and download the latest version for OS X (x64). Double click on the node-v4.2.2.pkg file (latest stable version at the writing of the post) and follow the installation instructions steps.

When ready open a terminal window and check the version installed to see if it is working:

$ node --version

Terminal Window

Set background black

Open Terminal, then go to the Terminal menu -> Preferences, choose the Settings tab and set the Pro theme as the default.

To quickly test that everything works I generated a

Often Used UNIX Keys on the German/Swiss Keyboard

I bought the Mac Book to use it as developer machine on the go and one of my initial surprises was the missing of some keys a developer/terminal user uses pretty often like []|{}~

So here it is, my personal keyboard map reminder for the Mac OS X:

| pipe symbol <alt>7
\\ backslash <alt><shift>7 = <alt>/
[ left (opening) square bracket <alt>5
] right (closing) square bracket <alt>6
{ left (opening) curly bracket <alt>8
} right (closing) curly bracket <alt>9
~ Tilde <alt>n followed by the space key
@ “At” symbol

 <alt>g (lowercase G)

How to Test Everything is Working

A smoke test to verify if everything installed is functioning properly “together” is to generate an application with JHipster and push it to git repository.

JHipster is a Yeoman generator, used to create a Spring Boot + AngularJS project.

If you have any suggestions please leave a comment. Thank you.

From Idea to Application gives you the architecture to quickly build, manage and run a range of applications (web, mobile, big data, new smart devices, etc.) on an open-standard, cloud-based platform. See why developers are using IBM Bluemix. Brought to you in partnership with IBM.

java,maven,git,intellij,mac os x

Published at DZone with permission of Adrian Matei, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}