0

This is my java code...I want to make it double click run forever after compiling once..! Please Guide me How can I make this .. ?

import java.util.Scanner;
public class Functions {
public static int addnumbers(){
Scanner input = new Scanner(System.in);
    int a,b;
    System.out.println("\nMethod Call - Addition");
    System.out.print("\nEnter a = ");
    a=input.nextInt();
    System.out.print("Enter b = ");
    b=input.nextInt();
    return(a+b);        
}
public static int subnumbers(){
Scanner input = new Scanner(System.in);
    int a,b;
    System.out.println("Method Call - Subtraction");
    System.out.print("\nEnter a = ");
    a=input.nextInt();
    System.out.print("Enter b = ");
    b=input.nextInt();
    return(a-b);        
}
public static int mulnumbers(){
Scanner input = new Scanner(System.in);
    int a,b;
    System.out.println("Method Call - Multiply");
    System.out.print("\nEnter a = ");
    a=input.nextInt();
    System.out.print("Enter b = ");
    b=input.nextInt();
    return(a*b);        
}
public static int quonumbers(){
Scanner input = new Scanner(System.in);
    int a,b;
    System.out.println("Method Call - Quotient");
    System.out.print("\nEnter a = ");
    a=input.nextInt();
    System.out.print("Enter b = ");
    b=input.nextInt();
    return(a/b);        
}
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
int n;
System.out.println("**Calcultor**\n\n1.Addition\n2.Subtraction\n3.Multiplication\n4.Quotient");
System.out.print("\nEnter no : ");
n=input.nextInt();
if(n==1) {
System.out.println("\nResult = "+addnumbers());
}
if(n==2) {
System.out.println("\nResult = "+subnumbers());
}
if(n==3) {
System.out.println("\nResult = "+mulnumbers());
}
if(n==4) {
System.out.println("\nResult = "+quonumbers());
}
System.out.println("\nControl exit!");
 }
}

Tell me any way to do this....

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190
Cute Doll
  • 3
  • 2
  • 1
    Possible duplicate http://stackoverflow.com/questions/147181/how-can-i-convert-my-java-program-to-an-exe-file – gla3dr Nov 19 '13 at 21:47
  • It sounds like he wants to have a standalone .exe that can be kicked off directly without a client having to wrap anything else. – seand Nov 19 '13 at 21:49
  • 1
    Why do you want to do this? even VC++ programs use a runtime library. – Peter Lawrey Nov 19 '13 at 21:51
  • Check the question gla3dr posted for how to create an executable. However, if you want the program to run more than once, you will need to put in some type of loop in the main method. `while(true)` putting everything other than the scanner in the while loop would keep it running, but in a more useful program you would have some type of boolean that the user can change to make the program exit. – DoubleDouble Nov 19 '13 at 21:53

1 Answers1

0

These are programs that wrap the Jar file and dependencies to create a native executable for Windows.

Pedantic
  • 5,032
  • 2
  • 24
  • 37