Java Code Examples for com.sun.jna.Platform#getOSType()
The following examples show how to use
com.sun.jna.Platform#getOSType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CanonLibraryImpl.java From canon-sdk-java with MIT License | 6 votes |
/** * <p>Method is called at every call of {@link #edsdkLibrary()}</p> */ protected void initLibrary() { if (EDSDK == null) { synchronized (initLibraryLock) { if (EDSDK == null) { final String libPath = getLibPath() .orElseThrow(() -> new IllegalStateException("Could not init library, lib path not found")); if (Platform.isWindows()) { // no options for now EDSDK = Native.loadLibrary(libPath, EdsdkLibrary.class, new HashMap<>()); registerCanonShutdownHook(); log.info("Library successfully loaded"); return; } throw new IllegalStateException("Not supported OS: " + Platform.getOSType()); } } } }
Example 2
Source File: PtyUtil.java From WebIDE-Backend with BSD 3-Clause "New" or "Revised" License | 6 votes |
private static String getPlatformFolder() { String result; if (Platform.isMac()) { result = "macosx"; } else if (Platform.isWindows()) { result = "win"; } else if (Platform.isLinux()) { result = "linux"; } else if (Platform.isFreeBSD()) { result = "freebsd"; } else if (Platform.isOpenBSD()) { result = "openbsd"; } else { throw new IllegalStateException("Platform " + Platform.getOSType() + " is not supported"); } return result; }
Example 3
Source File: PtyUtil.java From WebIDE-Backend with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static String getNativeLibraryName() { String result; if (Platform.isMac()) { result = "libpty.dylib"; } else if (Platform.isWindows()) { result = "winpty.dll"; } else if (Platform.isLinux() || Platform.isFreeBSD() || Platform.isOpenBSD()) { result = "libpty.so"; } else { throw new IllegalStateException("Platform " + Platform.getOSType() + " is not supported"); } return result; }
Example 4
Source File: HostnameUtilsLinuxTest.java From netbeans with Apache License 2.0 | 4 votes |
@Override public boolean canRun() { return super.canRun() && Platform.LINUX == Platform.getOSType(); }
Example 5
Source File: HostnameUtilsUnixTest.java From netbeans with Apache License 2.0 | 4 votes |
@Override public boolean canRun() { return super.canRun() && Platform.FREEBSD == Platform.getOSType(); }
Example 6
Source File: HostnameUtils.java From netbeans with Apache License 2.0 | 3 votes |
/** * Gets the name which is likely to be the local host's primary * name on the network. * * <p> * IMPLEMENTATION: * <p> * <ul> * <li>On Unix-like OSes (incl Mac OS X) this is the value as returned from * the {@code gethostname()} function from the standard C Library. </li> * <li>On Windows it is the value as returned from the * {@code gethostname()} function from {@code Ws2_32} library. * (without domain name). Note that this Windows function will do a * name service lookup and the method is therefore potentially blocking, * although it is more than likely that Windows has cached this result * on computer startup in its DNS Client Cache and therefore the * result will be returned very fast.</li> * </ul> * * @return host name * @throws NativeException if there was an error executing the * system call. */ public static String getNetworkHostname() throws NativeException { switch(Platform.getOSType()) { case Platform.WINDOWS: return org.netbeans.core.network.utils.hname.win.HostnameUtilsWin.getHostName(true); case Platform.MAC: return org.netbeans.core.network.utils.hname.mac.HostnameUtilsMac.cLibGetHostname(); case Platform.LINUX: return org.netbeans.core.network.utils.hname.linux.HostnameUtilsLinux.cLibGetHostname(); case Platform.SOLARIS: return org.netbeans.core.network.utils.hname.solaris.HostnameUtilsSolaris.cLibGetHostname(); default: return org.netbeans.core.network.utils.hname.unix.HostnameUtilsUnix.cLibGetHostname(); } }