Question: Given the following code in Java, and using the program Eclipse: public class Euclid { public static void main(String args[]) { int gcd; int a=Integer.parseInt(args[0]);

Given the following code in Java, and using the program Eclipse:

public class Euclid {

public static void main(String args[]) { int gcd; int a=Integer.parseInt(args[0]); int b=Integer.parseInt(args[1]); System.out.println(); System.out.println("------------------"); System.out.println("Euclid's Algorithm by Nicolas Kemball-Cook"); System.out.println("Inputs:"+a+" , "+b); System.out.println(); if(a>b) { calGcd(a,b); } else { calGcd(b,a); } } public static void calGcd(int a, int b) { int q, r=10,mul; while (r!=0) { q=a/b; mul=q*b; r=a-mul; System.out.println(a+" x "+b+" + "+r); a=b; b=r; } if(r==0) { System.out.println("GCD :"+a); } } }

Explain how to do the following:

1. Run your Java code in Eclipse using a run configuration that passes 2 sample inputs

2. When you are happy with how the program operates, export an executable JAR file to your desktop.

3. make sure the box for the JAR includes the source file

4.Open a command window and navigate to your desktop Test your JAR by running it with some sample input values, for example: "java -jar Euclid.jar 5763 187"

5. Verify that your JAR contains your Java source file by using the "jar tvf " command

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!