Shikhil Saxena

Aug 31, 2025 • 1 min read

🖥️ Building a Java Desktop App with a Web UI

The article explores how to create a cross-platform Java desktop application using a modern web-based UI built with:

  • React

  • Tailwind CSS

  • TypeScript

  • shadcn/ui (a component library)

Instead of using outdated Java UI toolkits like Swing or JavaFX, the app embeds a Chromium-based web view via JxBrowser, allowing developers to leverage the flexibility and polish of web technologies.

🧱 Key Architecture Highlights

✅ App Window

  • Built using JFrame (Swing)

  • Embeds a browser view powered by JxBrowser

🌐 Web UI Loading

  • Development mode: Loads from localhost with hot reload

  • Production mode: Loads from internal resources using a custom jxb:// protocol via JxBrowser’s UrlRequestInterceptor

This avoids the need for external servers and protects the app’s source code from inspection.

🔄 Java ↔ Web Communication

Option 1: Direct JavaScript-Java Bridge

  • Java methods exposed via @JsAccessible

  • JavaScript calls Java methods directly

Option 2: Protobuf + gRPC

  • Defines a type-safe API using .proto files

  • Generates Java and TypeScript code

  • Uses gRPC for structured communication between frontend and backend

This approach is more scalable and maintainable for larger apps.

🎯 Conclusion

Using web UIs in desktop apps simplifies development, improves UI quality, and taps into a rich ecosystem of tools. The article provides a practical guide to embedding React-based UIs in Java apps while maintaining secure, offline-ready architecture

Join Shikhil on Peerlist!

Join amazing folks like Shikhil and thousands of other builders on Peerlist.

peerlist.io/

It’s available... this username is available! 😃

Claim your username before it's too late!

This username is already taken, you’re a little late.😐

0

1

0