Documentation Home
MySQL Connector/J 8.0 Developer Guide
Related Documentation Download this Manual
PDF (US Ltr) - 474.9Kb
PDF (A4) - 476.4Kb
HTML Download (TGZ) - 114.9Kb
HTML Download (Zip) - 132.7Kb


4.3 Installing from Source

Caution

Read this section only if you want to build a customized version of Connector/J from source, or if you are interested in helping us test our new code. To just get MySQL Connector/J up and running on your system, install Connector/J using a standard binary release distribution; see Section 4.1, “Installing Connector/J from a Binary Distribution” for instructions.

To install MySQL Connector/J from source, make sure that you have the following software on your system:

To build MySQL Connector/J from source, follow these steps:

  1. Make sure that you have JDK 1.8.x installed.

  2. Obtain the sources for Connector/J by one of the following means:

    • Download the platform independent distribution archive (in .tar.gz or .zip format) for Connector/J, which contains the sources, from the Connector/J Download page. Extract contents of the archive into a folder named, for example, mysql-connector-j.

    • Download a source RPM package for Connector/J from Connector/J Download page and install it.

    • Check out the code from the source code repository for MySQL Connector/J located on GitHub at https://github.com/mysql/mysql-connector-j. The latest release of the Connector/J 8.0 series is on the release/8.0 branch; use the following command to check it out:

      shell> git clone --branch release/8.0 https://github.com/mysql/mysql-connector-j.git

      Under the current directory, the command creates a mysql-connector-j subdirectory , which contains the code you want.

  3. Place all the required third-party libraries in a separate directory—for example, /home/username/ant-extralibs.

  4. Change your current working directory to the mysql-connector-j directory created in step 2 above.

  5. In the directory, create a file named build.properties to indicate to Ant the locations of the root directories for your JDK 1.8.x installation, as well as the location of the extra libraries. The file should contain the following property settings, with the path_to_* parts replaced by the appropriate file paths:

    com.mysql.cj.build.jdk=path_to_jdk_1.8
    com.mysql.cj.extra.libs=path_to_folder_for_extra_libraries

    Alternatively, you can set the values of those properties through the Ant -D options.

    Note

    Going from Connector/J 5.1 to 8.0, a number of Ant properties for building Connector/J have been renamed or removed; see Section 4.4.1.4, “Changes for Build Properties” for details.

  6. Issue the following command to compile the driver and create a .jar file for Connector/J:

    shell> ant dist

    This creates a build directory in the current directory, where all the build output goes. A directory is created under the build directory, whose name includes the version number of the release you are building. That directory contains the sources, the compiled .class files, and a .jar file for deployment.

    For information on all the build targets, including those that create a fully packaged distribution, issue the following command:

    shell> ant -projecthelp
  7. Install the newly created .jar file for the JDBC driver as you would install a binary .jar file you download from MySQL by following the instructions given in Configuring the CLASSPATH or Configuring Connector/J for Application Servers.