Create Java apps using SQL Server on RHEL
In this section, you will get SQL Server 2017 on Red Hat Enterprise Linux (RHEL). 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.
-
Register the Microsoft Linux repository.
curl https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo | sudo tee /etc/yum.repos.d/mssql-server-2017.repo
-
Install SQL Server.
sudo yum update sudo yum install 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 RHEL 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 yum install java-1.8.0-openjdk
Loaded plugins: langpacks, product-id, search-disabled-repos
Resolving Dependencies
--> Running transaction check
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.111-2.b15.el7_3 will be installed
--> Processing Dependency: java-1.8.0-openjdk-headless = 1:1.8.0.111-2.b15.el7_3
for package: 1:java-1.8.0-openjdk-1.8.0.111-2.b15.el7_3.x86_64
--> Processing Dependency: fontconfig(x86-64) for package: 1:java-1.8.0-openjdk-
1.8.0.111-2.b15.el7_3.x86_64
--> Processing Dependency: libjava.so(SUNWprivate_1.1)(64bit) for package: 1:jav
a-1.8.0-openjdk-1.8.0.111-2.b15.el7_3.x86_64
--> Processing Dependency: libjli.so(SUNWprivate_1.1)(64bit) for package: 1:java
...
Installed:
java-1.8.0-openjdk.x86_64 1:1.8.0.111-2.b15.el7_3
Step 1.3 Install Maven
Maven can be used to help manage dependencies, build, test and run your Java project.
sudo wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
sudo sed -i s/\$releasever/6/g /etc/yum.repos.d/epel-apache-maven.repo
sudo yum install maven
Loaded plugins: langpacks, product-id, search-disabled-repos
Resolving Dependencies
--> Running transaction check
---> Package maven.noarch 0:3.0.5-17.el7 will be installed
--> Processing Dependency: aether-api for package: maven-3.0.5-17.el7.noarch
--> Processing Dependency: aether-connector-wagon for package: maven-3.0.5-17.el7.noarch
--> Processing Dependency: aether-impl for package: maven-3.0.5-17.el7.noarch
--> Processing Dependency: aether-spi for package: maven-3.0.5-17.el7.noarch
--> Processing Dependency: aether-util for package: maven-3.0.5-17.el7.noarch
...
Installed:
maven.noarch 0:3.0.5-17.el7
Check that you have Maven properly installed by running the following command.
mvn -v
Apache Maven 3.0.5 (Red Hat 3.0.5-17)
Maven home: /usr/share/maven
Java version: 1.8.0_111, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-2.b15.el7_3.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-327.36.3.el7.x86_64", arch: "amd64", family: "unix"
Note: If you’re using an older version of Java, such as 1.7, your results above may differ slightly. If you want to use an updated version of Java, please update your Java home variable.
You have successfully installed Java and Maven on RHEL. You now have everything you need to start writing your Java apps with SQL Server!
Have Questions?
Happy to help! You can find us on GitHub, MSDN Forums, and StackOverflow. We also monitor the #SQLServerDev hashtag on Twitter.