How to Install Oracle SQL Developer on Ubuntu 20.04
Tags: ubuntu, sql, oracle, sqldeveloper
Published: 2020-07-26 09:14:50

This is a fairly straightforward guide to install Oracle SQL Developer on Ubuntu 20.04

# Gathering Files

### Prerequisite
* Oracle JDK 8/11
* Oracle SQL Developer

### Downloading Prerequisite
#### Oracle JDK 8/11
1. Go to [download Oracle JDK page](https://www.oracle.com/java/technologies/javase-downloads.html)
2. I will use Oracle JDK 11 because it has a .deb installation file which can be easily installed using `dpkg`
![Oracle JDK Download Page](https://dev-to-uploads.s3.amazonaws.com/i/pjdpze3w9750w6iwugsh.png)
3. Download Oracle JDK 11 for Debian package (at the time of this post, the version is 11.0.8), you will be prompted to sign in using oracle account to download
![Oracle JDK 11 Download Page](https://dev-to-uploads.s3.amazonaws.com/i/5i83nb0g5h0e5zxvilw8.png)

#### Oracle SQL Developer
1. Go to [download Oracle SQL Developer page](https://www.oracle.com/tools/downloads/sqldev-downloads.html)
2. Download Oracle SQL Developer for Other Platforms (at the time of this post, the version is 20.2)
![Oracle SQL Developer Download Page](https://dev-to-uploads.s3.amazonaws.com/i/ql45yhvgdb6e8l98u7zr.png)

### Prerequisite Completed
![Prerequisite Completed](https://dev-to-uploads.s3.amazonaws.com/i/sy2a8brpzpoi0kq4pcik.png)

# Installation

### Install Oracle JDK 11 and Oracle SQL Developer
#### Oracle JDK 11
1. Open your terminal, go to directory where your prerequisite files are located (in my case it's in `~/Downloads`)
![Files](https://dev-to-uploads.s3.amazonaws.com/i/swmchn3i7n34gd98apf7.png)
2. Install Oracle JDK 11 by using command `sudo dpkg -i [YOUR_ORACLE_JDK_PACKAGE.deb]`, in my case it's `sudo dpkg -i jdk-11.0.8_linux-x64_bin.deb`
![Install Oracle JDK 11](https://dev-to-uploads.s3.amazonaws.com/i/6s5qpgn31w6mvn9q1rq0.png)
3. Verify your installation by listing the directory of `/usr/lib/jvm`
![Verify Oracle JDK 11](https://dev-to-uploads.s3.amazonaws.com/i/nghlpkb7ou106dxjkcu7.png)

#### Oracle SQL Developer 20.2
1. Open your terminal, go to `/opt` directory. This is where i will store the sqldeveloper application, you can choose other directory, but this my preference (and i read also that `/opt` is for 3rd party apps that we cannot install via `apt` package manager)
![Go To opt](https://dev-to-uploads.s3.amazonaws.com/i/696229jqwfbfdifs8t2g.png)
2. Unzip Oracle SQL Developer with command `sudo unzip [YOUR_SQL_DEVELOPER_FILE_WITH_LOCATION].zip`, in my case it's `sudo unzip ~/Downloads/sqldeveloper-20.2.0.175.1842-no-jre.zip`. By default the `unzip` program will extract the zip file into the current directory, since we are in `/opt` now, we don't need to specify target directory.
![Successfully Unzip](https://dev-to-uploads.s3.amazonaws.com/i/udcxhfd0ytqej3jdcmkf.png)
3. Locate your Oracle JDK installation under `/usr/lib/jvm`, we'll need this location to tell Oracle SQL Developer where our Oracle JDK is located. In my case it's `/usr/lib/jvm/jdk-11.0.8`
4. Go inside the `sqldeveloper` directory
![Inside sqldeveloper Directory](https://dev-to-uploads.s3.amazonaws.com/i/x3lo577hxako3astu2ok.png)
5. You can see that `sqldeveloper.sh` has executable permission so that we can run it by doing `./sqldeveloper.sh` or `sh sqldeveloper.sh` in the current directory.
6. Run the `sqldeveloper.sh` file, you will be prompted to enter the Oracle JDK location, just paste it in and press enter
![Fill in JDK Path](https://dev-to-uploads.s3.amazonaws.com/i/vfpbfft36otm9tj3ys3o.png)
7. You will see Oracle SQL Developer starting
![Loading](https://dev-to-uploads.s3.amazonaws.com/i/p9y5kjz4utirvdr5phq8.png)
![Started](https://dev-to-uploads.s3.amazonaws.com/i/i9nvdas8xu8gp8xbb1p9.png)
8. Installation done! You can use the application by executing the `sqldeveloper.sh`

At this point, the installation process is done and we can use the application. But it's quite troublesome for us to always open the terminal and execute the script to run the application.

# Create a Shortcut

#### Create a link to our `sqldeveloper.sh`
1. Open your terminal and type command `sudo ln -s [YOUR_SQLDEVELOPER.SH_PATH] /usr/local/bin/sqldeveloper`, in my case it's `sudo ln -s /opt/sqldeveloper/sqldeveloper.sh /usr/local/bin/sqldeveloper`
2. Verify that link has been created.
![Link has been created](https://dev-to-uploads.s3.amazonaws.com/i/5995i0p1x822qcz3iyna.png)
3. Now we can execute our application with command `sqldeveloper` from any directory. The reason why we put our link inside `/usr/local/bin` is so that it's available globally.
4. Go to your `$HOME` directory and execute the command `sqldeveloper`. You will get an error like this.
![Executing sqldeveloper error](https://dev-to-uploads.s3.amazonaws.com/i/jraiy7uz1d3jx2az9e04.png)
5. The error happened because it's trying to execute a syntax inside `sqldeveloper.sh` that uses relative path to navigate the directory. To fix this problem, what we need to do is edit the `sqldeveloper.sh` to execute the sqldeveloper binary
6. Open `sqldeveloper.sh` with your text editor. In my case, i will use `vim`. Remember to use `sudo` because this file belongs to `root`. Your file content should look like this now.
![Old](https://dev-to-uploads.s3.amazonaws.com/i/kuk3v3ylxyb2r6mum64a.png)
7. We will tell this script to execute the sqldeveloper binary directly without navigating to other directory by using this command `/opt/sqldeveloper/sqldeveloper/bin/sqldeveloper $*`, your file should look like this now.
![New](https://dev-to-uploads.s3.amazonaws.com/i/qxnlrxm0m8sk38o6topg.png)
8. Save the file and try `sqldeveloper` command again, you should be able to start Oracle SQL Developer now.

#### Create a desktop shortcut
1. Desktop shortcuts are stored in `/usr/share/applications` with `.desktop` extension. So we will create a new file in that directory with the name `sqldeveloper.desktop`.
![Create Desktop File](https://dev-to-uploads.s3.amazonaws.com/i/shlt3g5olr36n7bj6u51.png)
2. Inside your file should look like this.
```
[Desktop Entry]
Name=Oracle SQL Developer
Comment=SQL Developer from Oracle
GenericName=SQL Tool
Exec=/usr/local/bin/sqldeveloper
Icon=/opt/sqldeveloper/icon.png
Type=Application
StartupNotify=true
Categories=Utility;Oracle;Development;SQL;
```
3. Save your file
4. Verify that your shortcut is available to use by searching in application menu.
![Shorcut](https://dev-to-uploads.s3.amazonaws.com/i/oz9au239m5ej0zkxtqr2.png)

And that's it. You have completed the installation and created shortcut for Oracle SQL Developer.