|
Lines 44-50
Link Here
|
| 44 |
public static final int OS_SOLARIS = 2;//since 0.9.0 |
44 |
public static final int OS_SOLARIS = 2;//since 0.9.0 |
| 45 |
public static final int OS_MAC_OS_X = 3;//since 0.9.0 |
45 |
public static final int OS_MAC_OS_X = 3;//since 0.9.0 |
| 46 |
|
46 |
|
| 47 |
private static int osType = -1; |
47 |
private static int osType = OS_LINUX; |
| 48 |
|
48 |
|
| 49 |
/** |
49 |
/** |
| 50 |
* @since 2.3.0 |
50 |
* @since 2.3.0 |
|
Lines 77-180
Link Here
|
| 77 |
public static final String PROPERTY_JSSC_PARMRK = "JSSC_PARMRK"; |
77 |
public static final String PROPERTY_JSSC_PARMRK = "JSSC_PARMRK"; |
| 78 |
|
78 |
|
| 79 |
static { |
79 |
static { |
| 80 |
String libFolderPath; |
80 |
System.loadLibrary("jssc"); |
| 81 |
String libName; |
|
|
| 82 |
|
| 83 |
String osName = System.getProperty("os.name"); |
| 84 |
String architecture = System.getProperty("os.arch"); |
| 85 |
String userHome = System.getProperty("user.home"); |
| 86 |
String fileSeparator = System.getProperty("file.separator"); |
| 87 |
String tmpFolder = System.getProperty("java.io.tmpdir"); |
| 88 |
|
| 89 |
//since 2.3.0 -> |
| 90 |
String libRootFolder = new File(userHome).canWrite() ? userHome : tmpFolder; |
| 91 |
//<- since 2.3.0 |
| 92 |
|
| 93 |
String javaLibPath = System.getProperty("java.library.path");//since 2.1.0 |
| 94 |
|
| 95 |
if(osName.equals("Linux")){ |
| 96 |
osName = "linux"; |
| 97 |
osType = OS_LINUX; |
| 98 |
} |
| 99 |
else if(osName.startsWith("Win")){ |
| 100 |
osName = "windows"; |
| 101 |
osType = OS_WINDOWS; |
| 102 |
}//since 0.9.0 -> |
| 103 |
else if(osName.equals("SunOS")){ |
| 104 |
osName = "solaris"; |
| 105 |
osType = OS_SOLARIS; |
| 106 |
} |
| 107 |
else if(osName.equals("Mac OS X") || osName.equals("Darwin")){//os.name "Darwin" since 2.6.0 |
| 108 |
osName = "mac_os_x"; |
| 109 |
osType = OS_MAC_OS_X; |
| 110 |
}//<- since 0.9.0 |
| 111 |
|
| 112 |
if(architecture.equals("i386") || architecture.equals("i686")){ |
| 113 |
architecture = "x86"; |
| 114 |
} |
| 115 |
else if(architecture.equals("amd64") || architecture.equals("universal")){//os.arch "universal" since 2.6.0 |
| 116 |
architecture = "x86_64"; |
| 117 |
} |
| 118 |
else if(architecture.equals("arm")) {//since 2.1.0 |
| 119 |
String floatStr = "sf"; |
| 120 |
if(javaLibPath.toLowerCase().contains("gnueabihf") || javaLibPath.toLowerCase().contains("armhf")){ |
| 121 |
floatStr = "hf"; |
| 122 |
} |
| 123 |
else { |
| 124 |
try { |
| 125 |
Process readelfProcess = Runtime.getRuntime().exec("readelf -A /proc/self/exe"); |
| 126 |
BufferedReader reader = new BufferedReader(new InputStreamReader(readelfProcess.getInputStream())); |
| 127 |
String buffer = ""; |
| 128 |
while((buffer = reader.readLine()) != null && !buffer.isEmpty()){ |
| 129 |
if(buffer.toLowerCase().contains("Tag_ABI_VFP_args".toLowerCase())){ |
| 130 |
floatStr = "hf"; |
| 131 |
break; |
| 132 |
} |
| 133 |
} |
| 134 |
reader.close(); |
| 135 |
} |
| 136 |
catch (Exception ex) { |
| 137 |
//Do nothing |
| 138 |
} |
| 139 |
} |
| 140 |
architecture = "arm" + floatStr; |
| 141 |
} |
| 142 |
|
| 143 |
libFolderPath = libRootFolder + fileSeparator + ".jssc" + fileSeparator + osName; |
| 144 |
libName = "jSSC-" + libVersion + "_" + architecture; |
| 145 |
libName = System.mapLibraryName(libName); |
| 146 |
|
| 147 |
if(libName.endsWith(".dylib")){//Since 2.1.0 MacOSX 10.8 fix |
| 148 |
libName = libName.replace(".dylib", ".jnilib"); |
| 149 |
} |
| 150 |
|
| 151 |
boolean loadLib = false; |
| 152 |
|
| 153 |
if(isLibFolderExist(libFolderPath)){ |
| 154 |
if(isLibFileExist(libFolderPath + fileSeparator + libName)){ |
| 155 |
loadLib = true; |
| 156 |
} |
| 157 |
else { |
| 158 |
if(extractLib((libFolderPath + fileSeparator + libName), osName, libName)){ |
| 159 |
loadLib = true; |
| 160 |
} |
| 161 |
} |
| 162 |
} |
| 163 |
else { |
| 164 |
if(new File(libFolderPath).mkdirs()){ |
| 165 |
if(extractLib((libFolderPath + fileSeparator + libName), osName, libName)){ |
| 166 |
loadLib = true; |
| 167 |
} |
| 168 |
} |
| 169 |
} |
| 170 |
|
| 171 |
if (loadLib) { |
| 172 |
System.load(libFolderPath + fileSeparator + libName); |
| 173 |
String versionBase = getLibraryBaseVersion(); |
81 |
String versionBase = getLibraryBaseVersion(); |
| 174 |
String versionNative = getNativeLibraryVersion(); |
82 |
String versionNative = getNativeLibraryVersion(); |
| 175 |
if (!versionBase.equals(versionNative)) { |
83 |
if (!versionBase.equals(versionNative)) { |
| 176 |
System.err.println("Warning! jSSC Java and Native versions mismatch (Java: " + versionBase + ", Native: " + versionNative + ")"); |
84 |
System.err.println("Warning! jSSC Java and Native versions mismatch (Java: " + versionBase + ", Native: " + versionNative + ")"); |
| 177 |
} |
|
|
| 178 |
} |
85 |
} |
| 179 |
} |
86 |
} |
| 180 |
|
87 |
|