import java.io.*;
import java.util.Scanner;

public class jbin
{
	public static void jarToBinary(String jar, String binary) throws IOException, InterruptedException
	{
		try {
			// Deletes file if exists.
			Process pClear = Runtime.getRuntime().exec(new String[]{"rm", "-rf", binary});
			pClear.waitFor();

			// Creates blank file.
			Process pTouch = Runtime.getRuntime().exec(new String[]{"touch", binary});
			pTouch.waitFor();

			// Creates executable binary.
			try {
				byte[] buffer = new byte[(int) (new File(jar)).length()];

				FileInputStream shebangInputStream = new FileInputStream("shebang.txt");
				FileInputStream jarInputStream = new FileInputStream(jar);

				int shebangRead = 0;
				int jarRead = 0;

				while((jarRead = jarInputStream.read(buffer)) != -1 && (shebangRead = shebangInputStream.read(buffer)) != -1) {
					FileOutputStream outputStream = new FileOutputStream(binary);

          outputStream.write(buffer);
          outputStream.close();
				}

				shebangInputStream.close();
				jarInputStream.close();
			} catch (FileNotFoundException e) {
				System.out.println("Unable to open file '" + jar + "'.");
			} catch (IOException e) {
				System.out.println("Error reading file '" + jar + "'.");
			}

			// Allow execution.
			Process pExecute = Runtime.getRuntime().exec(new String[]{"chmod", "+x", binary});
			pExecute.waitFor();
		} catch (InterruptedException e) {
			System.out.println(e.getMessage());
		}
	}

	public static void sourceToJAR()
	{

	}

	public static void main(String[] args) throws IOException, InterruptedException {
		jbin.jarToBinary("HelloWorld.jar", "HelloWorld");
	}
}

@@ -1270,113 +1270,310 @@
 %0A%09%09%09
-Process pExecute = Runtime.getRuntime().exec(new String%5B%5D%7B%22chmod%22, %22+x%22, binary%7D);%0A%09%09%09pExecute.waitFor();
+try %7B%0A%09%09%09%09File binaryFile = new File(binary);%0A%0A%09%09%09%09binaryFile.setExecutable(true);%0A%09%09%09%7D catch (SecurityException e) %7B // If permissions are not sufficient.%0A%09%09%09%09System.out.println(%22Unable to set '%22 + binary + %22' to executable.%22);%0A%09%09%09%09System.out.println(%22Do this manually with: chmod +x %22 + binary);%0A%09%09%09%7D
 %0A%09%09%7D

Replace Runtime execution code with Java File/IO API for setting as executable.