About Paris Apostolopoulos

Paris is a senior software engineer focusing on J2EE development, loves Business process modelling and is keen on software quality challenges. He is passionate about Java and Java communities. He is a co-founder and administrator of the first Java User Group in greece(JHUG.gr) and occasional speaker on meet-ups and seminars and regular blogger.

Setup JAVA_HOME, MAVEN_HOME, ANT_HOME in MacOSX Lion in 5 minutes

I have been getting the very same question all the time, from people trying to make it through the world of Java development on the Mac. One of the first things they have to tackle is setting up the appropriate tools and enviroment.

Luckily enough MacOSX (Lion or previous flavors) have still lots of important tools for java development, integrated and ready to use. The main 3 tools usually needed are the following.

  • Java (of course) – it is not pre installed by default. All you need to do is open the Terminal.app and type something like java -version. Then a pop-up will appear asking you to install the latest available run time (at the time being is still Java 6)
  • Apache Ant – is already pre-installed! (1.8.2 at the time being – Lion 10.7.1)
  • Apache Maven – is already pre- installed. (3.0.3 at the time being – Lion 10.7.1)

So all the basic tools are there – all you need to do is set-up the enviroment by defining the HOME variables usually needed by other tools like IDE, app servers etc.

All you have to do is create a special file on your home folder and use some basic script commands like export – to indicate the paths of the tools. Really easy.

1.Go to your home folder, that would be something like

cd \Users\yourUserName

   In my system that would be

cd \Users\papo

2.Create a new file using vi or vim (or whatever you like) with the following command

vi .profile

3.Using (vim) in the file – just add the following lines

export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
export ANT_HOME=/usr/share/ant/
export MAVEN_HOME=/usr/share/maven/

4.Save the file (vi -> press Esc and :w) (see vi basic commands here)
5.Ready, open a new Terminal tab or window and test if your enviroment variables are all set by typing

echo $JAVA_HOME 
echo $ANT_HOME
echo $MAVEN_HOME

This is it your enviroment variables are ready, MacOSX has already integrated Java, Ant and Maven executables to the system path.

Notes:
Some paths may change in the future – you can always check where each tool is pre-installed by using the ‘which‘ and ‘ls -al’ command.

So if you are wondering where Ant has gone just type the following

which ant

Which is going to return something like /usr/bin/ant

Then just use the path above and use ls to see the real path of the symbolic link

ls -al /usr/bin/ant

This is going to return something like 22 Jul 30 19:38 /usr/bin/ant /usr/share/ant/bin/ant

Hope that helps! Enjoy!

Reference: Setup JAVA_HOME, MAVEN_HOME, ANT_HOME in MacOSX Lion in 5 minutes from our JCG partner Paris Apostolopoulos at the Papo’s log blog.

Related Articles :

Related Whitepaper:

Functional Programming in Java: Harnessing the Power of Java 8 Lambda Expressions

Get ready to program in a whole new way!

Functional Programming in Java will help you quickly get on top of the new, essential Java 8 language features and the functional style that will change and improve your code. This short, targeted book will help you make the paradigm shift from the old imperative way to a less error-prone, more elegant, and concise coding style that’s also a breeze to parallelize. You’ll explore the syntax and semantics of lambda expressions, method and constructor references, and functional interfaces. You’ll design and write applications better using the new standards in Java 8 and the JDK.

Get it Now!  

Leave a Reply


+ nine = 16



Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.

Sign up for our Newsletter

15,153 insiders are already enjoying weekly updates and complimentary whitepapers! Join them now to gain exclusive access to the latest news in the Java world, as well as insights about Android, Scala, Groovy and other related technologies.

As an extra bonus, by joining you will get our brand new e-books, published by Java Code Geeks and their JCG partners for your reading pleasure! Enter your info and stay on top of things,

  • Fresh trends
  • Cases and examples
  • Research and insights
  • Two complimentary e-books
Get tutored by the Geeks! JCG Academy is a fact... Join Now
Hello. Add your message here.