简体   繁体   中英

how to execute a runnable jar file in eclipse

just made a calculator type simple program....I need a way to compile it to ruanable jar...how do I do this in eclipse...I'm very new to programming so pardon me if I'm not very clear in my question...

here's my source code

   package lvlup;
   import java.awt.color.*;
   import java.math.*;
   import java.util.Scanner;


   public class methods {

    public methods(){
        System.out.println("Choose an option/n");
        System.out.println(" press 1 for derivative calculator (known polynomials)");

        int Choice;
        Scanner c = new Scanner(System.in);
        Choice = c.nextInt();

        switch (Choice){

        case 1:
            derCal();

        }

    }

    private void derCal() {
        double x;
        double n;
        long der;
        Scanner sc = new Scanner (System.in);

        System.out.println("welcome to the derivative calc");
        System.out.println("insert x");

        x = sc.nextDouble();

        System.out.println("insert n now/ n=1 default");

        n = sc.nextDouble();
        der = (long) (n*Math.pow(x, n-1));

        System.out.println("the answer is :" + der);

    }

    public static void main (String args []){methods m = new methods();

    }
   }

To create a new runnable JAR file in the workbench:

  1. From the menu bar's File menu, select Export.
  2. Expand the Java node and select Runnable JAR file. Click Next.
  3. In the Opens the Runnable JAR export wizard Runnable JAR File Specification page, select a 'Java Application' launch configuration to use to create a runnable JAR.
  4. In the Export destination field, either type or click Browse to select a location for the JAR file.
  5. Select an appropriate library handling strategy.
  6. Optionally, you can also create an ANT script to quickly regenerate a previously created runnable JAR file.

source: http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftasks-37.htm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM