NOISSUE implement direct java launch

Just running the Java process and giving it params on the command line
This commit is contained in:
Petr Mrázek
2016-06-16 02:20:23 +02:00
parent 57c84ec2b1
commit 1f2bed2ef1
31 changed files with 990 additions and 627 deletions

View File

@ -186,95 +186,5 @@ public class Utils
{
System.out.println();
}
/**
* Pushes bytes from in to out. Closes both streams no matter what.
* @param in the input stream
* @param out the output stream
* @throws IOException
*/
private static void copyStream(InputStream in, OutputStream out) throws IOException
{
try
{
byte[] buffer = new byte[4096];
int len;
while((len = in.read(buffer)) >= 0)
out.write(buffer, 0, len);
} finally
{
in.close();
out.close();
}
}
/**
* Replace a 'target' string 'suffix' with 'replacement'
*/
public static String replaceSuffix (String target, String suffix, String replacement)
{
if (!target.endsWith(suffix))
{
return target;
}
String prefix = target.substring(0, target.length() - suffix.length());
return prefix + replacement;
}
/**
* Unzip zip file with natives 'source' into the folder 'targetFolder'
*
* Contains a hack for OSX. Yay.
* @param source
* @param targetFolder
* @throws IOException
*/
public static void unzipNatives(File source, File targetFolder) throws IOException
{
ZipFile zip = new ZipFile(source);
boolean applyHacks = false;
String[] javaVersionElements = System.getProperty("java.version").split("[.\\-+]");
int major = Integer.parseInt(javaVersionElements[0]);
if(major == 1)
{
major = Integer.parseInt(javaVersionElements[1]);
}
if (major >= 8)
{
applyHacks = true;
}
try
{
Enumeration entries = zip.entries();
while (entries.hasMoreElements())
{
ZipEntry entry = (ZipEntry) entries.nextElement();
String entryName = entry.getName();
String fileName = entryName;
if(applyHacks)
{
fileName = replaceSuffix(entryName, ".jnilib", ".dylib");
}
File targetFile = new File(targetFolder, fileName);
if (targetFile.getParentFile() != null)
{
targetFile.getParentFile().mkdirs();
}
if (entry.isDirectory())
continue;
copyStream(zip.getInputStream(entry), new BufferedOutputStream(new FileOutputStream(targetFile)));
}
} finally
{
zip.close();
}
}
}