December 5, 2023
by Matt Raines

Salesforce Data Loader works on Ubuntu

Supported versions of Dataloader with "NOT THE WHOLE TRUTH" imposed

Salesforce has a handy tool to insert, update, and delete bulk data from CSV, XML, or JSON files. Salesforce says the tool only works on Windows and MacOS.

This can only be for lack of a QA team because not only is the tool written in platform-independent Java, but the download includes all the code you need to run it on Linux including a secret install script.

Here’s how to get it working in a few easy steps.

Hat tip: I took inspiration from Johannes F Knauf’s posts on how to get Data Loader working on Linux but honestly it’s even easier than it was then. You don’t need Wine or any extra libraries and you don’t even need a copy of Windows to install it on first.

Download the library

Download the “MacOS and Windows” version from https://developer.salesforce.com/tools/data-loader. It’s a ZIP archive which you should extract into a folder somewhere.

$ unzip dataloader_*.zip -d dataloader
Archive:  dataloader_v59.0.0.zip
   creating: dataloader/util/
  inflating: dataloader/dataloader-59.0.0.jar  
  inflating: dataloader/install.bat  
  inflating: dataloader/install.command  
  inflating: dataloader/util/util.bat  
  inflating: dataloader/util/util.sh  
   creating: dataloader/META-INF/
  inflating: dataloader/META-INF/MANIFEST.MF  
  inflating: dataloader/META-INF/stampy.SF  
  inflating: dataloader/META-INF/stampy.RSA  
$ cd dataloader

Looking at the contents of the dataloader-xx.xx.jar archive we can see it has a “linux” folder that contains everything we need to run the program.

$ jar tvf dataloader-*.jar
    238 Fri Sep 01 07:48:38 BST 2023 META-INF/MANIFEST.MF
      0 Fri Sep 01 07:48:38 BST 2023 META-INF/
      0 Fri Sep 01 07:48:32 BST 2023 org/
      0 Fri Sep 01 07:48:32 BST 2023 org/apache/
...
      0 Fri Sep 01 07:48:34 BST 2023 linux/
2104143 Fri Sep 01 07:48:34 BST 2023 linux/swtlinux_x86_64-4.28.jar
      0 Fri Sep 01 07:48:36 BST 2023 linux/util/
   1625 Fri Sep 01 07:48:36 BST 2023 linux/util/util.sh
    120 Fri Sep 01 07:48:36 BST 2023 linux/dataloader.sh
2092913 Fri Sep 01 07:48:34 BST 2023 linux/swtlinux_aarch64-4.28.jar
...

If you wanted to do this the hard way, you could extract the linux folder, move its contents into the current directory alongside the dataloader-xx.x.x.jar, delete the now empty folder, set the dataloader.sh script executable and run it.

But you may also have noticed the suspicious extension on that util/util.sh file extracted from the original archive. I guess it’s there to make the MacOS version work. And it’s got a handy flag for installing the program which is all that the Windows install.bat and MacOS install.command do anyway.

$ . util/util.sh
$ runDataLoader run.mode=install

Salesforce Data Loader running on Ubuntu

It launches the GUI and creates an executable dataloader.sh in the directory which you can use to run it in future.

Command line

You probably want to run Data Loader from the command line too. You were probably sad when you saw in the docs that “The Data Loader command-line interface is supported for Windows only”.

Also Not At All The Whole Truth.

All you need to do is replace a few commands in the documentation with slightly different commands. I see no reason this wouldn’t work on MacOS as well.

Changes to get command line data loader working on Linux
Where you see……replace it with
encrypt.bat./dataloader.sh run.mode=encrypt
process.bat./dataloader.sh run.mode=batch

For example, when you are told to run encrypt.bat -k [path to key file] to create an encryption key, you should instead run

$ ./dataloader.sh run.mode=encrypt -k [path to key file]

Hang on a minute

I’d written this whole article. I read it back. And I spotted something I hadn’t seen before.

It isn’t in the first page search results for “salesforce data loader”. It doesn’t tell you when you download the tool. It doesn’t tell you in the user guide. But it’s completely Open Source. The Github URL is right there in the application output that you can only see after you’ve already got the application running. Scroll up a bit and you’ll see it.

So I guess I could have saved myself all this hassle by downloading the version from GitLab and following the “Installing on Linux” instructions!

Possible problems

If you’re running the default version of Java in Ubuntu or you didn’t install Java before you might get an error at this point.

Data Loader requires Java JRE 17 or later. Checking if it is installed...
Found Java JRE version 11 whereas Data Loader requires Java JRE 17 or later.
Java JRE 17 or later is not installed or DATALOADER_JAVA_HOME environment variable is not set.

It’s pretty simple to fix. Find the latest version of the JRE and install it.

$ apt search "openjdk-.*-jre-headless"
Sorting... Done
Full Text Search... Done
default-jre-headless/jammy,now 2:1.11-72build2 amd64 [installed,automatic]
  Standard Java or Java compatible Runtime (headless)

openjdk-11-jre-headless/jammy-updates,jammy-security,now 11.0.21+9-0ubuntu1~22.04 amd64 [installed,automatic]
  OpenJDK Java runtime, using Hotspot JIT (headless)

openjdk-17-jre-headless/jammy-updates,jammy-security 17.0.9+9-1~22.04 amd64
  OpenJDK Java runtime, using Hotspot JIT (headless)

openjdk-18-jre-headless/jammy-updates,jammy-security 18.0.2+9-2~22.04 amd64
  OpenJDK Java runtime, using Hotspot JIT (headless)

openjdk-19-jre-headless/jammy-updates,jammy-security 19.0.2+7-0ubuntu3~22.04 amd64
  OpenJDK Java runtime, using Hotspot JIT (headless)

openjdk-21-jre-headless/jammy-updates,now 21.0.1+12-2~22.04 amd64 [installed]
  OpenJDK Java runtime, using Hotspot JIT (headless)

openjdk-8-jre-headless/jammy-updates,jammy-security 8u392-ga-1~22.04 amd64
  OpenJDK Java runtime, using Hotspot JIT (headless)

$ sudo apt install openjdk-21-jre-headless
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed
  openjdk-21-jre-headless
0 to upgrade, 1 to newly install, 0 to remove.
Need to get 46.9 MB of archives.
After this operation, 202 MB of additional disk space will be used.
Get:1 http://gb.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 openjdk-21-jre-headless amd64 21.0.1+12-2~22.04 [46.9 MB]
Fetched 46.9 MB in 5s (9,641 kB/s)                  
Selecting previously unselected package openjdk-21-jre-headless:amd64.
(Reading database ... 366646 files and directories currently installed.)
Preparing to unpack .../openjdk-21-jre-headless_21.0.1+12-2~22.04_amd64.deb ...
Unpacking openjdk-21-jre-headless:amd64 (21.0.1+12-2~22.04) ...
Setting up openjdk-21-jre-headless:amd64 (21.0.1+12-2~22.04) ...
update-alternatives: using /usr/lib/jvm/java-21-openjdk-amd64/bin/java to provide /usr/bin/java (java) in auto mode
update-alternatives: using /usr/lib/jvm/java-21-openjdk-amd64/bin/jpackage to provide /usr/bin/jpackage (jpackage) in auto mode
update-alternatives: using /usr/lib/jvm/java-21-openjdk-amd64/bin/keytool to provide /usr/bin/keytool (keytool) in auto mode
update-alternatives: using /usr/lib/jvm/java-21-openjdk-amd64/bin/rmiregistry to provide /usr/bin/rmiregistry (rmiregistry) in auto mode
update-alternatives: using /usr/lib/jvm/java-21-openjdk-amd64/lib/jexec to provide /usr/bin/jexec (jexec) in auto mode