Category "java"

Do lambda expressions have any use other than saving lines of code?

Do lambda expressions have any use other than saving lines of code? Are there any special features provided by lambdas which solved problems which weren't easy

why does tomcat show 404 response message for an existing resource?

I'm new to implementing web services and I'm doing it with jax-rs API using eclipse IDE for java-ee developers 2022. I have written a simple web service that re

CodeFights - issues with time limit when writing FirstDuplicate method

I'm trying to solve the problem below from CodeFights. I left my answer in Java after the question. The code works for all the problems, except the last one. Ti

java.lang.AbstractMethodError: com.mysql.jdbc.Connection.isValid(I)Z

I am trying to connect my Servlet to mysql database using data Source . But whenever I run my servlet I end up getting this exception : java.lang.AbstractMetho

HashMap and int as key

I am trying to build a HashMap which will have integer as keys and objects as values. My syntax is: HashMap<int, myObject> myMap = new HashMap<int, m

spring-boot ReactiveClientRegistrationRepository not found

Environment: Spring Boot 2.3.1, Java 11 I have tried out a few things already (also comparing with the sample-app by spring), but so far I have been unsuccessfu

Javamail Could not convert socket to TLS GMail

I'm trying to send an email using JavaMail through Gmail SMTP Server. This is the code: final String username = "[email protected]"; final String password = "my

How do I print a double value without scientific notation using Java?

I want to print a double value in Java without exponential form. double dexp = 12345678; System.out.println("dexp: "+dexp); It shows this E notation: 1.23456

How to find the tag Value in the dynamic JSON-Object with Java 8

I have JSON-object which has a dynamic key inside it. I need to get a specific value mapped to this dynamic Key. For example: value "10.00" will be returned for

Is there a way to make a 2nd click change the result?

I'm trying to make it when you click the cameraButton, the graphics show, but when clicked again, it closes. @Override public void paintComponent(Graphics g

What is the "proper" way to cast Hibernate Query.list() to List<Type>?

I'm a newbie with Hibernate, and I'm writing a simple method to return a list of objects matching a specific filter. List<Foo> seemed a natural return typ

Is it OK to add default implementations to methods of an interface which represents a listener?

There is a certain library I use in my project. This library has an interface which has about 15 methods. The purpose of this interface is to make it possible

Unable to Verify that GCS bucket and PKIX path building failed Errors in Creating and staging GCP Dataflow template

I am creating and staging gcp dataflow template in cloud storage with following command: mvn -X compile exec:java -Dexec.mainClass=main.java.TemplatePipeline -D

Modbus4J Modbus RTU master

Currently I am working with the Schneider Power Logic electrical device. I want to read the data from the device and show the value in my system. So far, I disc

How to securely store a user password in java for reuse throughout application

At the start of my Java application, I have the user enter his username and password. These credentials are stored in a ConnectionKey object which is used as th

Customize keycloak error page with spring boot

I use keycloak-spring-boot-starter to protect my rest-service from unauthorized access. The authentication works as expected, but if the authentication fails, t

Determine JDK home from Maven toolchain

I have a Maven build configured to use maven-toolchains-plugin, with ~/.m2/toolchains.xml simply configured for multiple JDKs: <?xml version="1.0" encoding=

QueryDSL: convert list of BooleanExpression to Predicate

I'm trying to create a query that would depend on number of boolean parameters. The function that creates the predicate looks like this: Predicate createPredic

Could not connect to http-remoting - Maven-Wildfly plugin

I am attempting to employ the functionality of Deploying to Wildfly 9 in my build process with the Wildfly-Maven plugin. I am unable to deploy the application,

Initialize field before super constructor runs?

In Java, is there any way to initialize a field before the super constructor runs? Even the ugliest hacks I can come up with are rejected by the compiler: cla