Yes, that was the problem. My user didn't belong to the cacheusr group. Now it's working. Thank you a lot!!!

There are 2 lines in /Cache/dev/cache/callin/samples/shdir.c:

char shdir[256] = "/Cache/mgr";
const char exeinfo[] = "User";

It's the correct path. The problem is that there is no "previous" shdir.
But how can the samples folder be involved in a JNI connection?

I reinstalled it again to make sure Unicode support is included. The version though doesn't have `U` at the end.

USER>WRITE $ZV

Cache for UNIX (Apple Mac OS X for x86-64) 2016.2.1 (Build 803U) Wed Oct 26 2016 12:36:07 EDT

It means I have two instances, the first one was removed, but it still remains default. I've cleared it, now the system recognises one default instance.

Now sudo ccontrol list gives me:

directory: /Cache
versionid: 2016.2.1.803.0
conf file: cache.cpf  (SuperServer port = 1972, WebServer = 57772)
status:    running, since Mon Feb 26 11:47:09 2018
state:     ok

The app gives me:

lc_conn::connect_device returned Db_err: source: lc_conn::connect() message: lc_conn::connect: CacheSecureStart returned -17: <INVALID_INSTANCE>

I've been checking a lot of stuff, and it's what I encountered after checking available instances:

Configuration 'DEFAULTCACHEINSTANCE' (default)
directory: /DefaultCacheInstance
versionid: 2017.1.1.111.0su
status: down, directory may be deleted

Configuration 'DEFAULTINSTANCE'
directory: /DefaultInstance
versionid: 2016.2.1.803.0
conf file: cache.cpf (SuperServer port = 1972, WebServer = 57772)
status: running, since Mon Feb 26 10:39:27 2018
state: warn

Yes, I have tried this as well as connection.connect(). I have tried connecting with incorrect parameters. The result is the same.