Create Java apps using SQL Server on Ubuntu
In this section, you will get SQL Server 2017 on Ubuntu. After that you will install the necessary dependencies to create Java apps with SQL Server.
Step 1.1 Install SQL Server
Note: To ensure optimal performance of SQL Server, your machine should have at least 4 GB of memory. If you need to get Ubuntu, check out the Ubuntu Downloads website.
Register the Microsoft Linux repositories and add their keys.
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list | sudo tee /etc/apt/sources.list.d/mssql-server-2017.list
Install SQL Server.
sudo apt-get update sudo apt-get install mssql-server
Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: mssql-server ... Unpacking mssql-server ... Setting up mssql-server ...
Setup your SQL Server.
sudo /opt/mssql/bin/mssql-conf setup
Microsoft(R) SQL Server(R) Setup To abort setup at anytime, press Ctrl-C. The license terms for this product can be downloaded from http://go.microsoft.com/fwlink/?LinkId=746388 and found in /usr/share/doc/mssql-server/LICENSE.TXT. Do you accept the license terms? If so, please type YES: Please enter a password for the system administrator (SA) account: Please confirm the password for the system administrator (SA) account:
You now have SQL Server running locally on your Ubuntu machine! Check out the next section to continue installing prerequisites.
Step 1.2 Install Java
If you already have Java installed on your machine, skip the next two steps. Install the Java Runtime Environment (JRE) using the following command.
sudo apt-get install default-jre
Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: default-jdk-headless Get:1 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 default-jre amd64 2:1.8-56ubuntu2 [980 B] ........... ........... Setting up default-jre (2:1.8-56ubuntu2) ...
Step 1.3 Install the Java Development Kit (JDK)
sudo apt-get install default-jdk
Reading package lists... Done Building dependency tree Reading state information... Done ....... ....... Preparing to unpack .../default-jdk_2%3a1.8-56ubuntu2_amd64.deb ... Unpacking default-jdk (2:1.8-56ubuntu2) ... Setting up default-jdk (2:1.8-56ubuntu2) ...
Step 1.4 Install Maven
Maven can be used to help manage dependencies, build, test and run your Java project.
sudo apt-get install maven
Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: maven ........ ........ Unpacking maven (3.3.9-3) ... Setting up maven (3.3.9-3) ... update-alternatives: using /usr/share/maven/bin/mvn to provide /usr/bin/mvn (mvn) in auto mode
Check that you have Maven properly installed by running the following command.
Apache Maven 3.3.9 Maven home: /usr/share/maven Java version: 1.8.0_111, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "4.4.0-45-generic", arch: "amd64", family: "unix"
You have successfully installed Java and Maven on your Ubuntu machine. You now have everything you need to start writing your Java apps with SQL Server!
Happy to help! You can find us on GitHub, MSDN Forums, and StackOverflow. We also monitor the #SQLServerDev hashtag on Twitter.