0

Im new in eclipse and i don't know how is it. to make my simple console application exported to .exe file, or anything to make my console app can be executable, without I open the eclipse IDE

this my only class i have, anyone can help me?

import java.util.Scanner;

public class MainClass {
    
    
    
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        
        Scanner key = new Scanner(System.in);
        
        System.out.println("### Selamat Datang di money Changer ###");
        System.out.print("Masukan Mata uang anda: ");
        String matauang = key.nextLine();
        System.out.print("Anda memasukan "+matauang.toUpperCase());
        System.out.print(" Masukan Nominal uang anda: ");
        String nilaI = key.nextLine();
        Integer hasilnya = money(matauang,Integer.parseInt(nilaI));
        System.out.print(" Rupiah yang anda tukar menjadi "+hasilnya+" "+matauang);

        
    }
    
    static Integer money(String matauang, Integer jml) {
        Integer hasil = 0;
        if(matauang.equals("Dolar")) {
            hasil = jml/11000;
        }else if (matauang.equals("Ringgit")) {
            hasil = jml/7000;
        }
        
        
        return hasil;
        
    }

}
Indra suandi
  • 141
  • 1
  • 3
  • 15
  • 2
    Does this answer your question? [How can I create a Windows .exe (standalone executable) using Java/Eclipse?](https://stackoverflow.com/questions/5719376/how-can-i-create-a-windows-exe-standalone-executable-using-java-eclipse) – shreyasm-dev Nov 05 '20 at 20:50

1 Answers1

0

To create an .exe launcher for a Java application, you should use the jpackage tool that is included in recent versions of the JDK.

https://docs.oracle.com/en/java/javase/14/docs/specs/man/jpackage.html

On Windows you need to use the --win-console option to make the .exe a console app instead of a GUI app. (Windows is the only operating system I am aware of that makes this unnecessary distinction.)

swpalmer
  • 3,890
  • 2
  • 23
  • 31