Java Community | Help. Code. Learn.

JCH

Java Community | Help. Code. Learn.

With more than 20,000 members, join one of the biggest and most active Java Communities on Discord! ☕

Join

java-help

❓︱qotw-answers

keeping track of clients connected to server

i have a server class that implements the runnable method, and i want to keep track of the clients connected to it so i can disconnect all of them via server class method. I've seen that a common practise is to use clientHandlers that are Runnable so that each client can run concurrently with the others, but i still dont get how to store the connected client object to the server (if its even possible)...

how to test my scheduled methods locally?

hey guys. so i have java spring app. in the app i have a 2 methods annotated with @Scheduled and each method has 2 cron expressions (one for work days, one for weekend). i deploy my app to the server. and on the same server i have cron jobs and thats how my code is being scheduled. but my question is how to locally test if my cron jobs for these two methods work fine?

how to properly update spring version?

hi guys. i have java project and current spring version is 2.2.6. i need to update the version to the newest. as i understand its 3.3.3. so i have a couple of questions; 1. since i use gradle, i just need to change the version here? ``` plugins { id 'org.springframework.boot' version '2.2.6.RELEASE'...

Spring Boot Oauth Login error

Im getting a java.lang.IllegalArgumentException: Invalid character found in the request target [/login?error=[authorization_request_not_found] ]. The valid characters are defined in RFC 7230 and RFC 3986 error when I try to login with google oauth setup on my spring backend. Here is my security config and oauthsuccess handler https://pastebin.com/raw/wKCKjxnN any help, please?...

Spring Boot Google OAuth error

Im getting a java.lang.IllegalArgumentException: Invalid character found in the request target [/login?error=[authorization_request_not_found] ]. The valid characters are defined in RFC 7230 and RFC 3986 error when I try to login with google oauth setup on my spring backend. Here is my security config and oauthsuccess handler https://pastebin.com/raw/wKCKjxnN any help, please?...

No response.

I'm currently working on a simple program that takes user input to create a gorcery list with prices and item names. It's not giving me any error codes when I run but rather nothing is appearing. I'll attach a photo below.
No description

I want to understand the need of keys in JPA (beginner)

Hi , Jpa entity in java to me is an interface for Database operations for classes . But , I don't understand need of defining primary key/foreign key in entities. It could be managed by database engines. To me , it seems like Database is a Data at rest concept while Entity is a data in transit concept...

Rock paper scissor

So I made a rock paper scissor game (im a beginner) and tried making it as simple to read, clean and professional as possible using methods (i didn't make classes because its a simple program) The program handles almost every type of error that can occur (I think) What else can I improve in my program? or is it good ...

Kerberos, SSO authentication doubt

I have an internal Java 17 spring-boot application with SSO validation using Kerberos and SPNEGO. Our setup includes the following: AD: Azure AD KDC: Multiple (Local) Application Host Server: Azure cloud...

What is inherited from ?

how do I find out which class is inherited from this I don't have anything
No description

Cants seem to get java to recognize a text file.

I cant seem to get java to recognize a text file
No description

Total price program

I've been trying to code a program that takes in user input to input it into an arraylist. I'm not sure what is going on here or why there are errors.
No description

Beginners doubt on JPA entity foreign mapping

Hi I am new to jpa's and am learning of foreign key mappings between two table. I need resources to learn on Jakarta JPA manytoone mappings. ...

how to return multiple objects in SOAP webservice?

hey guys. im developing SOAP webservice in java and i have a question. there are two operations checkId and createSale. and there are CheckIdRequestDTO, CheckIdResponseDTO, CreateSaleRequestDTO, CreateSaleResponseDTO. when validating checkId request and there are some errors, i set needed CheckIdResponseDTO fields to needed values and return the DTO and everything is fine. so my endpoint returns CheckIdResponseDTO in both cases: if its ok, or theres an error. But now im having trouble with createSale request. im validating CreateSaleRequestDTO, and if theres an error i dont have anything to return. I was thinking about constructing something like CreateSaleRequestErrorDTO. but then my endpoint cant return it. this is my endpoint so far: ```java @Endpoint @Validated public class PerlasEndpoint {...

what data type to use for storing ids?

hi guys. in java code i will need to use/store ids, that look like 11000000035. what data type to use? long or just String? because int in my case doesnt have enough storage for symbols. thanks

exception handling in SOAP webservices

hey guys. i have a question about SOAP webservice. i have this piece of code in my service layer: ```java Optional<Customer> customer=customerRepository.findById(Long.valueOf(perlasIdCheckRequestDTO.getUserId())); if (customer.isEmpty()) {...

SOAP service returns 404

hi guys. im developing SOAP web service. but when i call it with SOAP UI, i get ``` HTTP/1.1 404 X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block...

Any ideas how to render images in console?

Im writing cli application and was kinda inspired of super file It can preview images in fs (example is bellow) So, i decided to implement smth similar Any libs for that?...
No description