2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package com
.sun
.star
.sdbcx
.comp
.hsqldb
;
23 import java
.net
.URLClassLoader
;
25 final class NativeLibraries
{
26 public static void load() {
27 if (System
.getProperty( "os.name" ).startsWith("Windows")) {
28 loadLibrary("msvcr71");
30 loadLibrary("dbtoolsmi");
32 loadLibrary("hsqldb");
35 private static void loadLibrary(String libname
) {
36 // At least on macOS Tiger, System.loadLibrary("hsqldb2") does not
37 // find the hsqldb2 library one directory above sdbc_hsqldb.jar, even
38 // though ".." is on the jar's Class-Path; however, the alternative
39 // code (needing Java 1.5, which is given for macOS Tiger) works
42 System
.loadLibrary(libname
);
43 } catch (UnsatisfiedLinkError e
) {
44 ClassLoader cl
= NativeLibraries
.class.getClassLoader();
45 if (cl
instanceof URLClassLoader
) {
46 String sysname
= System
.mapLibraryName(libname
);
47 // At least Oracle's 1.7.0_51 now maps to .dylib rather than
49 if (System
.getProperty("os.name").startsWith("Mac")
50 && sysname
.endsWith(".dylib"))
54 0, sysname
.length() - "dylib".length())
57 URL url
= ((URLClassLoader
) cl
).findResource(sysname
);
60 System
.load(new File(url
.toURI()).getAbsolutePath());
61 } catch (Throwable t
) {
62 throw new UnsatisfiedLinkError(
63 e
.toString()+ " - " + t
.toString());
70 private NativeLibraries() {}