Java Community | Help. Code. Learn.

JCH

Java Community | Help. Code. Learn.

We are a Community full of Java developers. You can come here to connect other devs, get help, help others and do many more things!

Join

java-help

❓︱qotw-answers

unit testing error

I wrote this unit test: ```@WebMvcTest(CustomerController.class) public class CustomerControllerTest { @Autowired private MockMvc mockMvc; ...

git question, not a java question

I have a project on git, and I use github desktop to handle commits and pushes. For some reason, every time I open a branch, including main, it acts like none of my files have been added, and that I created them (when its a team project, and these files have been there for months). Its really tripping me up and making it harder to keep up with files I'm actually supposed to be working on in my branch. Anybody know what this is?

Overwriting a declared method?

Hello, I'm messing with something Java based, I want to modify it a bit. My code is simply this:
Method xyzMethod = XYZ.class.getDeclaredMethod("a", int.class, int.class, int.class, int.class, Random.class);
Method xyzMethod = XYZ.class.getDeclaredMethod("a", int.class, int.class, int.class, int.class, Random.class);
...

Type inference for generic parameters when calling a method

I was making a class with builder-type setters for generic member variables and I noticed something when I tried to pass it to a function accepting an object with a specialized generic argument for that type via new. Mainly this: ```java public static void bar(Foo<Integer> f){} public static class Foo<T>{ Foo<T> self(){...

quick help with a simple confusion

int result = 0; for (int i = 0; i < 4; i++) { result += 3; }...

Implementing a third-party PDF rendering library into a java extension

Hi, i'm trying to implement the icepdf library in an extension for a software. When I load the extension I get the following error: Thanks in advance....

Lombok @Data error

I'm getting this error
java: cannot find symbol
symbol: method getFirstName()
location: variable customerDto of type dto.CustomerDto
java: cannot find symbol
symbol: method getFirstName()
location: variable customerDto of type dto.CustomerDto
in this part of code: ```private Customer mapToCustomer(CustomerDto customerDto) throws Exception { if(customerDto.getFirstName().isEmpty() customerDto.getLastName().isEmpty() customerDto.getEmail().isEmpty() customerDto.getPassword().isEmpty() customerDto.getRole().isEmpty()) { throw new Exception("All fields must be filled");...

why my spring app cant connect to DB?

hi guys. im using intellij idea to run my java spring app. i connected my db to the intellij idea. ``` host: localhost port:5432 user:us3r...

someone explain this code (which i mostly understand

public static void main(String[] args) { int number = 0; while (true) { number = number + 1;...

why do i get redirected to /login?

hey guys. i have java spring app. it has this websecurity config chain: ```java @Override protected void configure(HttpSecurity http) throws Exception { http...

Is there a way to optimize my code more?

```java import java.util.*; public class Main { public static void main(String[] args) {...

javafx.fxml.LoadException

Hello. I use GravitLauncher for minecraft, I compiled my runtime module, but when I try to run it, it gives an error related to the controller (That the class could not be found), I have attached a detailed error below

confused as how to implement stars next to space "∆"

i am doing an assignment where you have to make a right-leaning triangle. However, I am confused as how to make the stars go be placed next to the "∆" (Place holder for " "). I tried using a for loop for the stars where they would supposedly be placed next to the space (∆), however, the output of the stars become jagged and the output overall doesn't look like a right-leaning triangle. Anyone out there who could help?
No description

java/scala multithreading on spark?

I'm using scala spark to get data from hudi table to hive table. I'm already maximizing optimization on spark with worker nodes and cluster size. Table is missing a lot of features that could improve the speed, but it's managed by other team and many other teams are also accessing this table (Thus table side change cannot happen). What I've not tried is multithreading from scala. Has any of you used java and spark, and applied java multithreading and saw noticeable improvement from data ETL duration?...

Spring Boot, Eureka Server shuts Service down

My Eureka Discovery Service always shuts down my services, although i configure it with `spring: application: name: test-service...
No description

Dealing with concurrent updates

Does anyone have suggestions on resources, concepts and topics to look into on handling concurrent updates? Like I have two different systems possibly updating the same record/object, how should I be handling concurrent updates to prevent duplicates and other issues. The two different systems have their own db but eventually the shared data has to be written in a middleware postgres db that has to handle the concurrent scenarios.

Can I make a superclass's variable static final in subclass?

```abstract class User { String about; } class Bots extend User { final static String about = "Bots are not humans"; // I think this replaces Superclass 's instance variable about...

Java Swing (jtextfield)

Boa tarde pessoal, tenho uma dúvida, quando executo este projeto, porque só digitar no swing ele não aparece os dados, mais ao pressionar o botão de = aí sim mostra o resultado da soma? Alguém pode me ajudar a resolver isso, para que quando eu digite os dados na tela gráfica, os dados já apareçam de imediato? Porque só está aparecendo após pressionar o botão de resultado!
No description

Code Help Please!

I have been trying to fit a function to a data set, but my function appears as linear line on gnuplot... what am I doing wrong?
No description

Converting int array to byte array

I am attempting to convert an array of ints to a byte array to store in a file which will later be read and converted back into an int array. these are my conversion methods: ```java public static byte[] intArrayToByteArray(int[] intArr) {...