Java Console Login System A straightforward Java console application for simple ID and password-based login. This project offers an easy introduction to basic authentication and loop control in Java, useful for beginners learning about user input, conditionals, and recursion.
Features Simple authentication: Prompts the user for an ID and password, and checks them against preset values.
Retry mechanism: If login fails, prompts the user to try again. The program repeats the login prompt as long as the user chooses to continue.
Clear success and error messages: Provides feedback on successful or failed logins.
Graceful exit: Allows users to exit the program at any point after a failed login.
Usage Download and compile
Make sure you have Java installed on your system (JDK 8 or later).
Save the file as login.java. Then, in your command prompt or terminal, run:
bash javac login.java Run the program
bash java login Interact with the application
When prompted, enter the ID and password. The defaults are both 123.
On successful login, you'll see:
text Welcome to code On failure, you'll see:
text Wrong id or pass Try again.....Then press y/Y...... You can press Y or y to try again, or any other key to exit.
Example text Enter id 123 Enter password 123 Welcome to code If login fails and you want to retry:
text Enter id 24 Enter password 57 Wrong id or pass Try again.....Then press y/Y...... y
Enter id 123 Enter password 123 Welcome to code If you do not want to retry:
text Wrong id or pass Try again.....Then press y/Y...... n good bye Notes The login credentials (ID and password) are hardcoded as 123. You can change these in the source code if needed.
The program exits gracefully if the user chooses to stop after failing to log in.
This project is intended for learning and demonstration purposes only; it is not secure for production use!
Requirements Java Development Kit (JDK) 8 or later.