Mac os JAVA development environment configuration brief

1. Mac comes with jdk1.6 (my machine is like this and the version that comes with the new Mac is not clear)

    First download jdk1.7 to
    download the dedicated jdk1.7 for the mac version, the address is as follows: http://jdk7.java .net/macportpreview/, which has the latest version (but still a beta version), the version update frequency will release a build every two weeks, the version I installed is b223 (update, the latest version is b227, it is no longer OpenJDK ).
    After downloading, double-click the dmg to open it, and then simply drag and drop (this is no nonsense, and it will not be dragged to the wall).
    Change the jvm preference order, search for [Java Preferences] in Spotlight (the Chinese version should be the JAVA preference?), you should be able to see several virtual machines that already exist, drag Java SE 7 to the top, and that’s it (For example, I dragged the 64-bit version).
    Confirm the version used by java: open a terminal, enter java -version, and confirm that the version number of jvm is jdk1.7.0.

2. Configure java_home

    Set the JAVA_HOME environment variable in the MAC The
    environment variable should be configured in the profile file in the etc directory, which is the permanent configuration.
    cd /etc
    vi profile

    Press i to enter write mode and

    enter the following:

    JAVA_HOME=/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home
    After export JAVA_HOME is

    finished, press the esc key to exit the write mode

    command [:wq!] Force save and exit

3. Install eclipse or myeclipse

    Here is to download and install eclipse is free, just download it and decompress it and use it. There is nothing to say.
    As for myeclipse, it is very difficult to find the address: http://pan.baidu.com/share/link?shareid=3668676447&uk=3580314255
    As for activation, you can solve it yourself. There are pj methods on the Internet

. 4. Modify the default jre

    open preference of eclipse- >Java->Installed JREs, see the JRE list on the right, if you have used the default jdk1.6, click Add, select MacOS X VM, and point to the installation location of jdk7 in the path.
    If you can't find where the damn jdk1.7 is installed, you can consider pasting this address (this is the location in my system, I guess everyone should be about the same). /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home

5. Install tomcat

    Download the latest Tomcat binary code package from the Apache website: (Be careful not to download the Windows installation package) http://tomcat.apache.org /
    After downloading, unzip and name the folder as Tomcat
    , move the renamed folder to the root directory /Library (other places can also), and the installation process is complete
    Execute startup.sh under /Library/Tomcat/bin, then open http://localhost:8080 to see if Tomcat has been started. If you want to stop the server, run shutdown.sh in the same directory.
    If you encounter problems such as unable to find directories and files The problem is usually caused by file permissions, which can be solved as follows:
    sudo chmod 755 /Library/Tomcat/bin/*.sh
    sudo chmod 755 /Library/Tomcat/bin/*.bat
    encounter "JAVA_HOME not defined" JAVA path Undefined error, execute the following command in the terminal:

    sudo setenv JAVA_HOME /Library/Java/Home
    Configure the Tomcat startup script:

    Use a text editor to add the following code:

    #!/bin/bash

    case $1 in
    start)
    sh /Library/Tomcat/ bin/startup.sh
    ;;
    stop)
    sh /Library/Tomcat/bin/shutdown.sh
    ;;
    restart)
    sh /Library/Tomcat/bin/shutdown.sh
    sh /Library/Tomcat/bin/startup.sh
    ;;
    *)
    echo “Usage: start|stop|restart”
    ;;
    esac

    exit 0

    Save the file as tomcat, lowercase without suffix. Place this file in a terminal included path, such as /usr/bin, and then simply type tomcat start and tomcat stop in the terminal to enable tomcat.
    The following errors may occur during the installation process:
    startup.sh: command not found .
    Add bash or sh or ./ before the command

    . It represents the current directory. If the execution program or script is not added to the environment variable PATH, add "." in front of the current directory. /"

    Executing the tomcat command in Terminal will prompt permission denied. Authorization is
    required. sudo chmod 755 /usr/bin/tomcat

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326032316&siteId=291194637