Set the Java Development Environment on the MacBook Pro

Source: Internet
Author: User
Tags macbook

Set the Java Development Environment on the MacBook Pro

Okay, I went to the other side of the earth, and because my PC is not there, only one MacBook Pro can be used for development. This article should be seen as an enhanced bookmarkdonet. I have listed all the necessary Installation Tools for the MacBook to achieve its purpose, that is, for Java and later for JavaScript development.

I still use Windows XP/7) and LinuxUbuntu/Mint/Cent OS until now ). When I was writing this article, I ran OS X Yosemite Version 10.10.5 on my MacBook Pro.

JDK

First, install the Java Development Kit JDK. This is a software development environment for developing Java applications and applets. It includes Java Runtime Environment JRE), Interpreter/loader Java), compiler javac), archive jar), documentation builder javadoc) and other tools required for Java development.

Download Mac OS X x64. dmg files

  • Java 7

  • Java 8

You can run the/usr/libexec/java_home-v 1.7 command on the terminal to find the JDK installation path:

 
 
  1. Adrians-MacBook-Pro:ama ama$ /usr/libexec/java_home -v 1.8 
  2.  
  3. /Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home 
  4.  
  5. Adrians-MacBook-Pro:ama ama$ /usr/libexec/java_home -v 1.7 
  6.  
  7. /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home 
  8.  
  9. Adrians-MacBook-Pro:ama ama$ 

For example, you need to know this when creating a project in IntelliJ idea.

Set JAVA_HOME

JAVA_HOME is just a convention and is usually used for Tomcat, other JavaEE program servers, and tools like Maven that can find the survival location of Java.

In Mac OSx 10.5 and later versions, Apple recommends setting $ JAVA_HOME to the path/usr/libexec/java_homeUnder, just set$JAVA_HOMEExport to file~/. bash_profileOr~/.profile.

 
 
  1. $ vim .bash_profile  
  2.  
  3. export JAVA_HOME=$(/usr/libexec/java_home) 
  4.  
  5. $ source .bash_profile 
  6.  
  7. $ echo $JAVA_HOME 
  8.  
  9. /Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home 

Maven

After setting JAVA_HOME in the method specified above, go to Apache Maven downloads, download the .tar.gz or. zip file, and select a folder to decompress it. I put it in the/opt Folder:

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

We recommend that you create a link to Maven for installation. If you want to update the Maven version, you only need to change the link target:

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

Then set Maven in the environment variable:

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

Close the terminal and open a new one. If you want to get the maven version, you should do the following:

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

Another option is to use Homebrew and run the following command:

 
 
  1. brew install maven 

Git

Open a terminal window and enter the following command:

 
 
  1. $git --version 

Next you need to install Xcode. If you want to develop applications on Apple TV, Apple Watch, iPhone, iPad, and Mac, this is a comprehensive set of developer tools. It includes Xcode IDE, simulators, and all the tools and frameworks required to create IOS, watchOS, tvOS, and OS X applications, as well as GNU Compiler Collection-gcc ).

You can install it according to the instructions above, but if you don't want to get everything from the installation package, you can install a Homebrew "Homebrew can install programs that you don't need but Apple does ."), And run the following command:

 
 
  1. brew install gcc 
  2. brew install git 

Either way, after Git installation is complete, the initial command git-version shows the installation version:

 
 
  1. $ git --version 
  2. git version 2.4.9 (Apple Git-60) 

If you use Github, we recommend that you install another Github Desktop.

IntelliJ

Generally, IIntelliJ is my favorite IDE, mainly because the functions required by front-end development are almost the same. To install it, go to the download page and follow the instructions to install it:

Installation Guide

  • Download the disk image file for idea-15.dmg OS X.

  • Attach it to another disk in the system.

  • Copy IntelliJ IDEA to the application folder.

Others

NodeJS

Node. js is the JavaScript runtime built on the V8 Javascript Engine on Chrome. Node. js uses event-driven, lightweight and efficient non-blocking I/O models. Node. js's ecosystem package, npm, is the world's largest open source library ecosystem. Recently, it has become a necessary tool for the front-end of the development program.

Go to https://nodejs.org/to download the latest OS Xx64 ). Double-click the node-v4.2.2.pkg file for the latest stable version before writing this article), follow the installation instructions.

When a terminal window is opened, check the installed version to see if it works:

$ Node -- version

V4.2.2

Terminal window

Black Background

Open the terminal and goTerminal menu-> Preferences, Select the Settings option, and set Protheme to default.

To quickly test whether everything is normal, I generated a Common UNIX Keys on German/Swiss Keyboard.

I bought a Mac Book as a development machine on my journey. At first, I was surprised that there were no buttons frequently used by developers/end users, such as [] | {}~

So here I listed the Mac OS x keyboard ing tips I used:

How to test everything

Note: The smoke test is a simple test of system functions. It emphasizes the coverage rate of the functions and does not verify the correctness of the functions. It can verify whether the functions of all installed tools are coordinated, it uses JHipster to generate an application and update it to the git repository.

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

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.