Начал изучать Java, написал первую программу, но хочу,чтобы она запускалась как стандартная программа по двойному клику с расширением .exe. Сейчас же эта программа при запуске в Idea отображается в консоли среды. Как это реализовать?
Программа генерирует название электронной почты и пароль для неё для нового сотрудника компании
Главный класс EmailApp:
package emailapp;
public class EmailApp {
public static void main(String[] args) {
Email em1 = new Email("Petya", "Ivanov");
System.out.println(em1.showInfo());
}
}
Класс Email:
package emailapp;
import java.util.Scanner;
public class Email {
private String firstName;
private String lastName;
private String password;
private String email;
private int defaultPasswordLength = 10;
private String department;
private String companySuffix = "supercompany.com";
private int mailboxCapacity = 500;
private String alternateEmail;
//Constructor to receive the first name and last name
public Email(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
//Call a method asking for the department - return the department
this.department = setDepartment();
//Call a method that returns a random password
this.password = randomPassword(defaultPasswordLength);
//Combine elements to generate email
email = firstName.toLowerCase() + "." + lastName.toLowerCase() + "@" + department + "." + companySuffix;
}
//Ask for the department
private String setDepartment() {
System.out.print("New worker: " + firstName + " " + lastName + "\nDepartment Codes: \n1 for Sales\n2 for Development\n3 for Accounting\n0 for none\nEnter department code: ");
Scanner in = new Scanner(System.in);
int depChoice = in.nextInt();
if (depChoice == 1) {return "sales";}
else if (depChoice == 2) {return "dev";}
else if (depChoice == 3) {return "acct";}
else {return "";}
}
//Generate a random password
private String randomPassword(int length) {
String passwordSet = "ABCDEFGHIKLMNOPQRSTUWXYZ0123456789!@#$%";
char[] password = new char[length];
for (int i = 0; i < length; i++) {
int rand = (int) (Math.random() * passwordSet.length());
password[i] = passwordSet.charAt(rand);
}
return new String (password);
}
//Set the mailbox capacity
public void setMailboxCapacity(int capacity) {
this.mailboxCapacity = capacity;
}
//set the alternate email
public void setAlternateEmail(String altEmail) {
this.alternateEmail = altEmail;
}
//Change password
public void changePassword(String password) {
this.password = password;
}
public int getMailboxCapacity() { return mailboxCapacity;}
public String getAlternateEmail() {return alternateEmail;}
public String getPassword() {return password;}
public String showInfo() {
return "DISPLAY NAME: " + firstName + " " + lastName +
"\nCOMPANY EMAIL: " + email +
"\nPASSWORD: " + password +
"\nMAILBOX CAPACITY: " + mailboxCapacity + "mb";
}
}