Installation of Oracle SQL Developer to Ubuntu

First of all, you need to install Java in your environment. I will continue with the latest OpenJDK version currently available. Easiest method to install jdk is to write following commands to the terminal:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install openjdk-8-jdk
[/sourcecode ]

Then you can download Oracle SQL Developer from <a href="http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html" target="_blank">official website</a>. You should choose the option for other platforms. After download has completed, we need to unzip the files in a suitable place. Considering that the most of the third party applications usually installed in <code>/opt</code>, for the rest of the operations I will use this directory. However, if you want to extract the zip content somewhere else, there is no restriction for that. Also, don't forget to give execution rights to run it from console easily.


cd ~/Downloads #go to downloads
sudo unzip sqldeveloper-*-no-jre.zip -d /opt/ #unzip sqldeveloper to /opt directory
sudo chmod +x /opt/sqldeveloper/sqldeveloper.sh #give execution rights
[/sourcecode ]

Now, everything is ready to run Oracle SQL Developer. You can run it calling sh file:

/opt/sqldeveloper/sqldeveloper.sh
[/sourcecode ]

When you run SQL Developer for the first time, you need to specify the path of JDK's folder. In default installation it is under: <code>/usr/lib/jvm/java-8-openjdk-amd64/</code>

For convenience and not to write full path to the console every time, it would be handy if we put caller script for sqldeveloper.sh to user's local directory (Note: symbolic link doesn't work since sqldeveloper.sh contains <code>`dirname $0`</code>). I will use gedit to create file since it is already in the operating system. If you want, you can use other text editors like sublime text, vim etc. 

sudo gedit /usr/local/bin/sqldeveloper

And put below content inside of the file and close it with saving.

/opt/sqldeveloper/sqldeveloper.sh

After you saved, you should also give execution rights to this file.

sudo chmod +x /usr/local/bin/sqldeveloper

From now on, you are able to run SQL Developer just writing sqldeveloper to command line. But if you want to run it like it is a desktop application, you should create a desktop entry like below:

sudo gedit /usr/share/applications/sqldeveloper.desktop

And add these lines to the file and save it:

[Desktop Entry]
Exec=sqldeveloper
Terminal=false
StartupNotify=true
Categories=GNOME;Oracle;
Type=Application
Icon=/opt/sqldeveloper/icon.png
Name=Oracle SQL Developer

Then you should update the desktop entries:

sudo update-desktop-database

Now, you can find SQL Developer using search bar in the left. Don’t forget to change Exec part of the desktop entry if needed. For example, if you haven’t created wrapper execution in /usr/local/bin/, you should write full path like /opt/sqldeveloper/sqldeveloper.sh.

If you have tns entries in your Oracle Home directory and want to see those entries in SqlDeveloper, you need to export ORACLE_HOME as an environment variable. There are couple of ways to do that and you can choose any of them. If you think ORACLE_HOME variable only going to be used with SQL Developer, you can edit sqldeveloper.sh using your favourite text editor. You need to add below lines before the line that runs SQL Developer(Assuming your client version is 12.2 and 64bit version. Otherwise you should make necessary changes):

export ORACLE_HOME=/usr/lib/oracle/12.2/client(64)

In the end, your /opt/sqldeveloper/sqldeveloper.sh should look like:

#!/bin/bash
export ORACLE_HOME=/usr/lib/oracle/12.2/client(64)
cd "`dirname $0`"/sqldeveloper/bin && bash sqldeveloper $*

Another way to add this environment variable is to add this export statement to your profile and bashrc files. To do that, you should edit the files in your home directory:

sudo gedit ~/.profile
sudo gedit ~/.bashrc

and add export ORACLE_HOME=/usr/lib/oracle/12.2/client(64) at the end of file. To make it active in current terminal window, you should run below commands:

source ~/.bashrc
source ~/.profile

As a last method, we can create a new script in our profile directory to be sure that ORACLE_HOME variable exported to environment during the start of system. Basically, we should create a file like:

sudo gedit /etc/profile.d/oracle.sh

and add export ORACLE_HOME=/usr/lib/oracle/12.2/client(64) then save it. After that, you can test it with restarting computer.

Note: If you are using older version of Ubuntu, you may need to unset GNOME_DESKTOP_SESSION_ID. To do that, you should edit shell script content.

sudo gedit /opt/sqldeveloper/sqldeveloper.sh

And add:

unset -v GNOME_DESKTOP_SESSION_ID

command before running SQL Developer.

Developers Rock!!!

Advertisements
This entry was posted in Linux, Oracle, Shell Script and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s