Wednesday, April 30, 2025

Creating Your First Java Swing Application Using Notepad

 Welcome back to My Java Journey! Today, we’re going old-school — no fancy IDEs, just Notepad, Command Prompt, and a simple Java Swing app you’ll code by hand.

We’re going to create a tiny desktop app that:
✅ Shows a label
✅ Has a textbox for you to enter your name
✅ Has a button that, when clicked, updates the label to say “Hello [your name]”

Let’s get started!


🗂️ Step 1: Prepare Your Project Folder

1️⃣ Open File Explorer and create a new folder at:

C:\hello

his is where you’ll save your .java file and compile the program.


📝 Step 2: Write the Java Code

1️⃣ Open Notepad.

2️⃣ Copy and paste this Java code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import javax.swing.*;
import java.awt.event.*;

public class HelloSwing {
    public static void main(String[] args) {
        JFrame frame = new JFrame("Hello Swing");
        JLabel label = new JLabel("Enter your name:");
        JTextField textField = new JTextField(15);
        JButton button = new JButton("Submit");

        label.setBounds(50, 50, 300, 20);
        textField.setBounds(50, 80, 150, 20);
        button.setBounds(50, 110, 100, 30);

        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String name = textField.getText();
                label.setText("Hello " + name + "!");
            }
        });

        frame.add(label);
        frame.add(textField);
        frame.add(button);

        frame.setSize(400, 250);
        frame.setLayout(null);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }
}

3️⃣ Save the file as:

C:\hello\HelloSwing.java

⚙️ Step 3: Compile the Code

1️⃣ Open Command Prompt.

  • Press Win + R, type cmd, and press Enter.

2️⃣ Navigate to your project folder:

cd C:\hello
3️⃣ Compile the Java file:
javac HelloSwing.java

✅ If successful, you’ll see no errors, and a HelloSwing.class file will appear in the folder.

▶️ Step 4: Run the Application

In the same Command Prompt window, type:

java HelloSwing

✅ A window should pop up with:

  • A label saying Enter your name:

  • A textbox

  • A button labeled Submit

When you type your name and press the button, the label updates to say:


Hello [your name]!

🔍 Quick Recap

✔️ Create project folder C:\hello
✔️ Write Java Swing code in Notepad
✔️ Compile using javac
✔️ Run using java

You’ve just built your first Java Swing application without an IDE — and that’s a great hands-on way to understand what’s happening under the hood.

Requirements to Develop a Web Application Using Java Spring, MySQL, and React.js

 If you want to build a full-stack web application with a Java Spring Boot backend, MySQL database, and React.js frontend, you’re combining some of today’s most popular tools into a powerful modern stack.

Here’s what you need to get started on your Windows 10 (or 11) laptop.


🏗️ Backend: Java Spring Boot + MySQL Requirements

Java Development Kit (JDK)

  • Download JDK 17 or later (LTS) from Oracle or Adoptium.

  • Make sure java -version works in your terminal or command prompt.

Maven or Gradle

  • These are build tools for managing project dependencies.

  • Spring Initializr (start.spring.io) helps generate a starter project using either.

  • Install Maven (if not bundled with your IDE) and ensure mvn -v works.

Spring Boot

  • You don’t “install” Spring Boot globally — you include it in your project using Maven or Gradle.

  • Use Spring Initializr to quickly bootstrap your project.

MySQL Database

  • Install MySQL Server (community edition) from mysql.com.

  • Install MySQL Workbench (optional, for GUI management).

  • Ensure mysql command-line tool or Workbench can connect to your database.

IDE

  • Use IntelliJ IDEA, Eclipse, or VS Code with Java and Spring extensions.

  • IntelliJ IDEA Community Edition works great with Spring Boot.

Postman or REST Client (optional)

  • For testing your backend APIs.


🎨 Frontend: React.js Requirements

Node.js and npm

  • Download and install from nodejs.org.

  • Check with:

node -v

React App

  • Use npx create-react-app your-app-name to scaffold a new React project.

Text Editor or IDE

  • Many use VS Code for React development, with helpful extensions like ESLint, Prettier, and React snippets.

Axios or Fetch

  • To connect your React frontend to the backend API.

npm or Yarn (for package management)

  • Comes bundled with Node.js, but some prefer installing Yarn.


🔗 How They Connect

Spring Boot REST API → exposes backend endpoints.
React.js frontend → calls backend APIs (usually via Axios or Fetch).
MySQL database → stores your application’s data, connected to Spring Boot using JPA or JDBC.


🏁 Summary Checklist

✅ Install JDK
✅ Install Maven or Gradle
✅ Install MySQL Server (and Workbench, optional)
✅ Install Node.js and npm
✅ Set up IDEs (IntelliJ, Eclipse, VS Code)
✅ Use Spring Initializr and Create React App to scaffold your projects

With all these in place, you’re ready to start building robust full-stack Java + React applications! 

Requirements to Build Java Swing Apps on a Windows 10 Laptop

 If you’re interested in building desktop applications with Java Swing on a Windows 10 laptop, you’re in for a classic yet powerful development experience. Swing has been part of Java since the late 1990s and remains a widely used GUI toolkit for building desktop apps.

This post walks you through:
✅ What you need installed
✅ How to check your Java version
✅ How to check your Java Swing version


🔍 1. What Do You Need to Get Started?

To build Java Swing applications on Windows 10, you need the following:

Java Development Kit (JDK)

  • Swing is part of the Java Standard Edition (SE), included in the JDK.

  • Download the latest JDK from Oracle or Adoptium (an open-source distribution).

An IDE or Text Editor (optional but recommended)

  • You can use any editor, but popular choices are:

    • IntelliJ IDEA (highly recommended, free Community Edition available)

    • Eclipse IDE

    • NetBeans IDE

    • Or even a simple editor like VS Code with Java extensions

Build Tools (optional)

  • If you plan to manage larger projects, tools like Maven or Gradle can help handle dependencies and builds.

Windows 10 laptop with enough RAM (4GB minimum, 8GB+ recommended)

  • Java itself doesn’t require much, but IDEs can be memory-hungry.


🖥️ 2. How to Check Your Java Version

To make sure Java is installed and accessible on your system:

1️⃣ Open Command Prompt (press Win + R, type cmd, press Enter)
2️⃣ Run:

java -version

You should see something like:

java version "17.0.2" 2022-01-18 LTS

Java(TM) SE Runtime Environment (build 17.0.2+8-LTS-86)

Java HotSpot(TM) 64-Bit Server VM (build 17.0.2+8-LTS-86, mixed mode, sharing)

Note: If you get an error like 'java' is not recognized, you need to add Java to your system’s PATH or install it.


🏗️ 3. How to Check Your Java Swing Version

Swing is included inside the JDK, specifically within the javax.swing package. It doesn’t have a separate version number—its version is tied to the JDK version.

However, you can programmatically check it by writing a simple Java program:

1
2
3
4
5
6
7
8
import javax.swing.UIManager;

public class SwingVersionChecker {
    public static void main(String[] args) {
        System.out.println("Java version: " + System.getProperty("java.version"));
        System.out.println("Swing version (UIManager): " + UIManager.class.getPackage().getImplementationVersion());
    }
}

Run this program, and you’ll get:

  • Your current Java version (same as java -version)

  • The Swing package version, which typically matches the Java version (or may return null depending on the JDK vendor).


🏁 Summary

✅ Install JDK (Java SE)
✅ Use an IDE or editor
✅ Check Java version with java -version
✅ Remember: Swing comes bundled with Java SE—no extra installation needed!

With this setup, you’re ready to start building desktop apps using Swing’s powerful set of GUI components like buttons, labels, tables, and more.

Welcome to My Java Journey

 Hi there! 👋 I’m excited to welcome you to My Java Journey, a personal space where I share what I’m learning, building, and discovering as I explore the world of Java programming.

Whether you’re a beginner just dipping your toes into Java or someone with experience looking for relatable stories and tips, this blog is for you. Here, you’ll find:
✅ Tutorials and code snippets
✅ Lessons learned from real projects
✅ Debugging tips and workarounds
✅ My honest reflections on the ups and downs of coding in Java

Java has been around for decades, but it’s still evolving — and so am I. I hope this blog becomes a helpful resource and maybe even a bit of inspiration as we navigate this journey together.

Thanks for stopping by, and happy coding! 💻☕✨

Deploying a React Frontend to Railway: A Complete Guide (To-Do App)

 If you've already deployed your Java Spring Boot backend to Railway, congratulations — the hardest part is done! 🎉 Now it’s time to ...