Reputation: 904
I have built a Java app that uses SQLite (sqlite-jdbc-3.8.7.jar) and have rolled everything into a jar file. Running the jar file on windows works as expected however, trying to run it on Ubuntu Server 14.04 has turned into quite a task! I put together a brand new virtual machine in VirtualBox for testing. I installed Java (sudo apt-get install default-jre) and have tried installing SQLite both from the repositories and by downloading the tar and compiling. SQLite installs just fine both ways as I can access it from terminal. I created a new sub-directory within my home directory and copied over my app jar file. From terminal, I then run the command: sudo java -jar .jar and I receive a java.lang.unsatisfiedlinkerror. See the attached image, what else must be done to get this working on Ubuntu? Any help would be appreciated!
Upvotes: 4
Views: 6636
Reputation: 81
Sqlite writes a native lib to a tmpdir and attempts to use it. If the tmp dir is on a filesystem mounted noexec, this will fail and may display an error like what you're seeing.
One way to avoid this is to set the java tmpdir as other answers have pointed out. Another is to remove noexec from your tmp fs.
To check:
$ mount | grep /tmp
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noexec,noatime,size=6291456k)
To change this, edit /etc/fstab, remove noexec from the /tmp line, then reboot or remount /tmp
;
$ mount -o remount /tmp
(Note that noexec
is considered a security feature, in that it prevents rogue apps from doing exactly what SQLite is trying to do here)
Upvotes: 4
Reputation:
Add this to your code and see if there are issues with your tmpdir...
final File tmp = new File(System.getProperty("java.io.tmpdir"));
if (!tmp.exists() || !tmp.isDirectory() || !tmp.canRead() || !tmp.canWrite()){
System.err.println("@PFTcreateDB - Issue with java.io.tmpdir");
}
This could indicate missing tmp or incorrect privileges.
Upvotes: 0
Reputation: 315
I have similar issue and revert to sqlite-jdbc-3.7.2 worked for me (Ubuntu 14.04 32bits)
Upvotes: 6
Reputation: 51
Well, I had similar issues and I had to revert to sqlite-jdbc-3.7.2.jar package because the driver in newer package for some reason didn't work under 64-bit linux on my (dreamhost so called vps) server. Newer package had no issues in Windows 8.1 x64. I also had to move tmp dir to home (System.setProperty("java.io.tmpdir", "/home/username/");).
Upvotes: 2