Source:
public static void main(final String[] args) { String serviceAccountEmailAddress = args[0]; String serviceAccountKey = null; try { serviceAccountKey = Files.toString(new File(args[1]), Charset.defaultCharset()); } catch (IOException e) { System.err.println("Cannot open service account private key PEM file: " + args[1] + "\n" + e.getMessage()); System.exit(1); } String userName = System.getProperty("user.name"); String sshPublicKeyFileName = System.getProperty("user.home") + "/.ssh/google_compute_engine.pub"; String sshPublicKey = null; try { sshPublicKey = Files.toString(new File(sshPublicKeyFileName), Charset.defaultCharset()); } catch (IOException e) { System.err.println("Cannot open your SSH public key at " + sshPublicKeyFileName + "\nIt is required to authorize your access to the machine.\n" + "See <LINK_0> for more details.\n" + e.getMessage()); System.exit(1); } String sshPrivateKeyFileName = System.getProperty("user.home") + "/.ssh/google_compute_engine"; String sshPrivateKey = null; try { sshPrivateKey = Files.toString(new File(sshPrivateKeyFileName), Charset.defaultCharset()); } catch (IOException e) { System.err.println("Cannot open your SSH private key at " + sshPrivateKeyFileName + "\nIt is required to perform any operations on your machine via SSH.\n" + "See <LINK_0> for more details.\n" + e.getMessage()); System.exit(1); } CreateServer createServer = new CreateServer(serviceAccountEmailAddress, serviceAccountKey); try { createServer.createServer(userName, sshPublicKey, sshPrivateKey); } catch (Exception e) { e.printStackTrace(); } finally { try { createServer.close(); } catch (IOException e) { e.printStackTrace(); System.exit(1); } } }

Target:
public static void main(final String[] args) { String serviceAccountEmailAddress = args[0]; String serviceAccountKey = null; try { serviceAccountKey = Files.toString(new File(args[1]), Charset.defaultCharset()); } catch (IOException e) { System.err.println("Cannot open service account private key PEM file: " + args[1] + "\n" + e.getMessage()); System.exit(1); } String userName = System.getProperty("user.name"); String sshPublicKey = null; String sshPrivateKey = null; String sshPublicKeyFileName = System.getProperty("user.home") + File.separator + ".ssh" + File.separator + "google_compute_engine.pub"; String sshPrivateKeyFileName = System.getProperty("user.home") + File.separator + ".ssh" + File.separator + "google_compute_engine"; try { sshPublicKey = Files.toString(new File(sshPublicKeyFileName), Charset.defaultCharset()); sshPrivateKey = Files.toString(new File(sshPrivateKeyFileName), Charset.defaultCharset()); } catch (IOException e) { System.err.println("Unable to load your SSH keys.\n" + e.getMessage() + "\nYour public key, which is required to authorize your access to the machine is expected to be at " + sshPublicKeyFileName + " , and your private key, which is required to perform any operations " + "on your machine via SSH, is expected to be at " + sshPrivateKeyFileName + " .\nSee <LINK_0> for more details.\n" + e.getMessage()); System.exit(1); } CreateServer createServer = new CreateServer(serviceAccountEmailAddress, serviceAccountKey); try { createServer.createServer(userName, sshPublicKey, sshPrivateKey); } catch (Exception e) { e.printStackTrace(); } finally { try { createServer.close(); } catch (IOException e) { e.printStackTrace(); System.exit(1); } } }