MRFramework/src/main/java/com/mr/util/CreateInstances.java
/**
	 * Copy jar and properties file from given location to EC2 instance /tmp
	 * location.
	 */
Copy jar and properties file from given location to EC2 instance /tmp
location.
Copy jar and properties file from given location to EC2 instance / tmp location .
private static void copyJarToInstances() {
		try {
			log.info("Copying Jar to all EC2 instances");
			for (String dns : activePublicDnsName) {
				ProcessBuilder pb1 = new ProcessBuilder("scp", "-i", pemKeysPath+pemKeys+".pem", "-o",
						"StrictHostKeyChecking=no", jarPath, "ec2-user@" + dns + ":/tmp");
				Process p1 = null;
				int error1 = -1;
				do {
					p1 = pb1.start();
					error1 = p1.waitFor();
				} while (error1 != 0);
				log.info(dns + "\tJar  = " + error1 + "\t");
				if (error1 == 0) {
					ProcessBuilder pb2 = new ProcessBuilder("scp", "-i", pemKeysPath+pemKeys+".pem", "-o",
							"StrictHostKeyChecking=no", "config.properties",
							"ec2-user@" + dns + ":/tmp");
					Process p2 = null;
					int error2 = -1;
					do {
						p2 = pb2.start();
						error2 = p2.waitFor();
					} while (error2 != 0);
					log.info("Config file  = " + error2);
					ProcessBuilder pb3 = new ProcessBuilder("scp", "-i", pemKeysPath+pemKeys+".pem", "-o",
							"StrictHostKeyChecking=no", "log4j.properties",
							"ec2-user@" + dns + ":/tmp");
					Process p3 = null;
					int error3 = -1;
					do {
						p3 = pb3.start();
						error3 = p3.waitFor();
					} while (error3 != 0);
					log.info("log4j Config file  = " + error3);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
private static void copyJarToInstances ( ) { try { log . info ( "Copying Jar to all EC2 instances" ) ; for ( String dns : activePublicDnsName ) { ProcessBuilder pb1 = new ProcessBuilder ( "scp" , "-i" , pemKeysPath + pemKeys + ".pem" , "-o" , "StrictHostKeyChecking=no" , jarPath , "ec2-user@" + dns + ":/tmp" ) ; Process p1 = null ; int error1 = - 1 ; do { p1 = pb1 . start ( ) ; error1 = p1 . waitFor ( ) ; } while ( error1 != 0 ) ; log . info ( dns + "\tJar  = " + error1 + "\t" ) ; if ( error1 == 0 ) { ProcessBuilder pb2 = new ProcessBuilder ( "scp" , "-i" , pemKeysPath + pemKeys + ".pem" , "-o" , "StrictHostKeyChecking=no" , "config.properties" , "ec2-user@" + dns + ":/tmp" ) ; Process p2 = null ; int error2 = - 1 ; do { p2 = pb2 . start ( ) ; error2 = p2 . waitFor ( ) ; } while ( error2 != 0 ) ; log . info ( "Config file  = " + error2 ) ; ProcessBuilder pb3 = new ProcessBuilder ( "scp" , "-i" , pemKeysPath + pemKeys + ".pem" , "-o" , "StrictHostKeyChecking=no" , "log4j.properties" , "ec2-user@" + dns + ":/tmp" ) ; Process p3 = null ; int error3 = - 1 ; do { p3 = pb3 . start ( ) ; error3 = p3 . waitFor ( ) ; } while ( error3 != 0 ) ; log . info ( "log4j Config file  = " + error3 ) ; } } } catch ( Exception e ) { e . printStackTrace ( ) ; } }
Copy jar and properties file from given location to EC2 instance /tmp
 location.
Copy jar and properties file from given location to EC2 instance / tmp location .