A
A
antoshka_basenko2022-02-11 16:30:29
Java
antoshka_basenko, 2022-02-11 16:30:29

How to create a Java application with a Web interface?

I want to create a simple Java application with a web interface.
Conditionally there is a page with a button and a field, I click on the button and let's say "Hello World" is displayed.
Of course, I don’t plan to put this application on a server or something like that, everything will be launched locally.
What is needed for this? What classes/libraries/frameworks should be used for this?
PS I can write an application in Java, I can make up a page, but I don’t understand how to “attach” it, but Google gives out how to make a complex application with installing it on a server and a bunch of unnecessary functions

Answer the question

In order to leave comments, you need to log in

5 answer(s)
D
Dmitry Roo, 2022-02-11
@xez

Here is a simple guide: https://spring.io/guides/gs/serving-web-content/
Plain html with thymeleaf template engine

T
Talyan, 2022-02-11
@flapflapjack

Apache Tomcat

S
Sergey Gornostaev, 2022-02-11
@sergey-gornostaev

I recommend starting by reading about servlets.

M
Michael, 2022-02-11
@Akela_wolf

Spring Boot solves your problem a little more than completely.
You open Spring initializr , mark the necessary features, get a ready-made application that can be run locally or even deployed on the server, if necessary.
And actually in this template you add any features you need.

O
Orkhan, 2022-02-11
Hasanly @azerphoenix

Good afternoon.

Conditionally there is a page with a button and a field, I click on the button and let's say "Hello World" is displayed.

If you need a very simple application, then you should start by learning about servlets.
Here's a simple example:
https://www.tutorialspoint.com/servlets/servlets-f...
If you need something more advanced, then the next step is to learn the Spring Framework (Spring Boot). Link - https://start.spring.io/
Of course, I don’t plan to put this application on a server or something like that, everything will be launched locally.

It is convenient to set up a servlet container for development locally using sdkman - https://sdkman.io/
If you use Spring Boot, then Spring Web has a built-in Tomcat. Accordingly, you can create a self-executing jar || war
What is needed for this? What classes/libraries/frameworks should be used for this?

Answered above. If you suddenly want to figure out how to get started with Spring Boot: https://www.youtube.com/watch?v=jH17YkBTpI4
I can write an application in Java, I can make up a page, but I don’t understand how to “attach” it

There may be various options here.
1) The simplest solution is to use template engines. For example, thymeleaf, mustache, freemarker. By the way, in the video tutorials above, there are examples with mustache & freemarker. But I prefer to work with thymeleaf.
2) A full-fledged backend REST application written in Java (Spring) and a full-fledged frontend application written in javascript or typescript (Vue, Angular, React). In this case, you don't need it.
To understand how to "attach" the template and your code... I think you need to understand the HTTP methods (GET, POST, PUT ...)
https://habr.com/ru/post/215117/
So you will understand how to submit the form content to the server, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question