Collect all kinds of java programming exceptions and fault solutions.


Overriding print statement in java based on object class

I have the following code in Java
I am able to print the calculated values in printDistance method.
Output:
4.0
3.0
But I need the output in below format(Expected Output).Please help
3D Distance = ...


How to autogenerate a Unique ID from Immutables Criteria Library?

The advice given on Immutables site is to switch to the new Immutables-Criteria functionality. In this sense I try to convert my project so that instead of Immutables-MongoDB it uses the Immutables-


In Java, how to let child class decide of which type parameter class use as overridden method argument?

I have an abstract class in which I want to have an abstract method taking in argument a Consumer functional interface and let the child class decide which type should parameterize the consumer.
I ...


Using Aeron with RSocket

Good morning,
I am trying to use RSocket on top of the Aeron transport protocol. However, it appears that there is no documentation on the topic - did anyone successfully integrate those two


How to convert java id in form of number in a character ASCII string?

I code some TextViews programatically and I want to provide them with ids. In the xml file I would have done something like:
android:id="@+id/btn0"
but in the .java file I'm allowed to set the id...


Creating a simple web application with Eclipse, Java, Gradle, Wildfly, Hibernate JPA, Spring and Angular

I've created several projects in Eclipse following online examples on how to create simple web applications with a combination of various technologies. I'm using Java 11 at the moment, Eclipse IDE (


Which package strategy use to achieve high cohesion and low coupling

My question is about achieve high cohesion but I think the next example promote low cohesion and high coupling and I would someone to explain me if this is the case or not, I am talking about the p...


Unable to invoke https REST endpoint through spring boot

I have to build a REST endpoint which is internally calling some REST Endpoints (Business Confidential) and will do some customization and give a user-specific response. Endpoints (Business Confide...


Look and feel of html page template after storing that in DOCX file with user data

I have developed an HTML and CSS web page template which looks like:
Once the user enters the data on this web page and clicks on the send button. My java application will trigger an e-mail along ...


'Cannot find symbol' when sorting a stream of files using compareToIgnoreCase (JShell)

Using JShell of java 13.0.1 on Debian Stretch:
import static java.nio.file.Files.*;
var hm=Path.of(System.getProperty("user.home"));
void p(String s) {System.out.println(s);}
list(...


HTTP Status 404 - Not found - Spring MVC and Hibernate

I am trying to run my application without using web.xml. Below is my code for webAppInitalizer
package com.restAPI.ResumeCreator.config;
import org.springframework.web.servlet.support.


Whether the Apache FTPClient.retrieveFile method creates temporary file

I am using Apache FTPClient for the Android. I download files from the server and overwrite them instead of local ones. I need to make sure that the files were downloaded correctly. Will the method


How does one compare Path equivalence in Java?

Given two Path objects p1 and p2 (that do not necessarily point to a file that exists), how do I check the underlying paths are equivalent? That is, Path objects arising from
/path/to/something
/p...


Kafka Streams : Flushing intermediate Windowed results as commit interval and window time are not in sync

Configuration for kafka Streams:
threads = 1;
replicationFactor = 1;
ktableCommitInterval= 10000;
ktableMemory=72000000;
timeDuration=10;
Topology:
KStream<Windowed<String>,String>


Maven ant task. Transitive (pom) dependencies and https issue

As you know, starting from 15 January 2020 Maven central repo requires HTTPS-only access. One of our projects is using Ant and Maven Ant Tasks (dependency management only). Yes, I know it's depreca...


Couldn't find PersistentEntity for type class debug error

I have the following piece of code that tries to insert a document object into mongoDB.
return reactiveMongoTemplate.insert(document)
.doOnSuccess(filler -> System.out.


Implement generic interface in a generic abstract class

Interface-
interface Service<T>
{
void foo(T t);
}
I want to create an abstract class that implements the Service interface. I don't want to provide the implementation for T i.e. generic.


Basic spring boot app not working, showing: Failed to refresh live data from process xxxx

I am beginner for spring boot. I initialized a new project and tried to run it but it does not work successfully. WHen I run this as spring boot application, it starts execution. In bottom compiler/


RestAssured: how to iterate through JSON object and validate each value of key fields

{
"body": {
"format": "json",
"query": {
"attributes": [
{
"field": "name",
"order": "none",
"hidden": false,
"label": "Computer"
...


Azure - Startup command - Unable to access jarfile app.jar

I have a Java Spring Boot application which is deployed on an Azure Webservice, it's all working. What I really want to do at this moment is the following:
"java -jar -Dspring.profiles.active=test...


Sample routine uisng JAVA APIs for T24

Can I have a sample routine (that has been tested) on latest T24/Transact release using Temenos Java APIs?
As per Temenos, Infobasic routines cannot be used anymore if EXTENSIBLE.CUSTOMISATION flag...


Java Spring Adding or removing @Component at runtime is possible?

I have something like this.
@Component public class JohnStephen
@Component public class Guadalupe
@Component public class CristianOrtiz
@Component public class CristinaCuellar
/*AND SO ON*/
All the


Java code to generate comma separated values and sum

While running this code I am getting ArrayIndexOutOfBoundsException.
public class Evensum {
public static void main(String[] args) {
int num = Integer.parseInt(args[0]);
int ...


JPA EntityManager.lock with H2 DB - java.sql.SQLException: Connection is closed when multiple Transactions use lock on same entity

I am implementing application where data blobs are downloaded. I want to make sure that when two download Transactions start around the same time, the first Transaction locks the data and I don't w...


How can I check whether the numbers in the array list are sequential

I want to check if numbers in an arraylist are sequential. The number in array start with 1, and for the next should be 2, 3, and 4. This means that every next element is 1 larger than the previous...


How do I use a variable from another method? (cannot find symbol - variable evenNum)

I am making a code that only prints the even numbers of an array. But I am having a problem sending evenNum variable from countEm to getAllEvens.
private static int countEm(int[] array)
{
...


Selenium Java - TestNG Data Providers using Getters and Setters

I am using Getters and Setters this within a Test Case and I am parsing an array to it. I then try to reference it later from another Test Case in a dataset controller class where I will pull the v...


What in particular restricts Quantum to one NPAPI plugin?

Firefox Quantum still supports NPAPI, but it is designed to load only the Adobe Flash Player plugin. It does not load the Java plugin or others. What in particular restricts Firefox Quantum to one ...


java.lang.NoSuchMethodError: No virtual method toString(Z)Ljava/lang/String; in class Lokhttp3/Cookie; or its super classe

I'm using retrofit (2.7.2) and OkHttp version (4.4.0) in an Android project and I'm facing a crash on a request.
Dependencies:
kapt("com.squareup.moshi:moshi-kotlin-codegen:1.9.2")
implementation...


AWS QLDB - Java Tutorial Step 2 (ConnectToLeger) - Unable to determine service/operation name to be authorized

I am trying to run the Java Tutorial from AWS found here:
https://docs.aws.amazon.com/qldb/latest/developerguide/getting-started.java.tutorial.html
In the first step of the guide I had to add the ...


How to display RecyclerView items after clicking on "View All" button

I am a beginner in android. I am creating an application where data will be shown through recyclerview, but I want that only some items should display in recyclerview.
However when the user clicks...


How to show localized date units in a formatted string in Java/Android?

Let's say I have a period of days:
Period p = Period.ofDays(3);
And I want to format the period with the "days" label in the string to get this string as output:
// "3 days"
...but, I want to


Can't properly hide the bottom navigation bar

I have created a drawer activity from the android studio templates and i did activate che full sticky immersive mode so that i don't always see the titlebar and the bottom navigation bar but the fa...


"Unnecessarily replacing a task that does not exist is not supported" - Error

I get this error when trying to run the code that is further below.
Unnecessarily replacing a task that does not exist is not supported. Use create() or register() >directly instead. You attem...


AzureSpringBootRequestHandler can't find function

I have a simple Spring Boot Function app with just 2 endpoints. Both produce a Exception: IllegalStateException: No function defined error with the following stacktrace:
[23/03/2020 14:16:57] 2020...


How to call methods in random order(Java JDK11)?

class Scratch {
public void meth1(){
}
public void meth2(){
}
public void meth3(){
}
public void meth4(){
}
public void meth5(){
}
public static void


When can I access an objects variable using object.variable?

Probably a simple question I should by now. I'm writing some code for a class and I have 1 class that I have 3 instance variables of
class LruC {
int counter
int RAM_address
boolean valid_invalid


Not able to delete in @OneToMany relationship spring data jpa

In my spring boot project, I have one LineItem entity below is the code
@Entity
@Table(name = "scenario_lineitem")
@Data
@NoArgsConstructor
public class LineItem implements Cloneable {


Verifying the number of times the method was called using Mockito?

I am new to mockito...
What I am trying to do is to use mockito and System.print out the number of times that a certain method was called...
For example,
The numer of times that the Class.doSometh...


Read file line by line and Access values from List<List<String>> for below specifications in java

The following 5 columns of character strings are stored as text file separated by tab code.
r1c1 = filename1 r1c2 = abc1 r1c3 = def1 r1c4 = ghi1 r1c5 = col51
r2c1 = filename2 r2c2 = abc2 r2c3 =


SwaggerUI doesn't show documented API properly generated by OpenApi codegen

I'm using openapi-generator-maven-plugin to generate code from YAML documentation.
openapi: 3.0.3
info:
title: Example API Doc
description: Those are example endpoints.
termsOfService: https://


2020-04-03 20:17:46 to "yyyy-MM-dd'T'HH:mm:ss" format

Is there any way in java(java.util.* or Joda api ) to convert "2020-04-03 20:17:46" to "yyyy-MM-dd'T'HH:mm:ss"
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss")
.parse("2020-04-03 20:17:46")...


How to disable the "Hypersistence Optimizer" Banner when using hibernate-types-52 in Spring Boot?

I use the com.vladmihalcea:hibernate-types-52 dependency in my Spring Boot Project. And I notices that on application boot, some large log messages where added:
2020-04-09 11:43:59.535 WARN 3465 ...


@Id doesn't create primary key

In my Spring Boot database project, I wanted this 'id' field to be auto-generated, unique Primary Key, but it's not. When I check the H2 database GUI there the Primary Key is some obscure, hidden 3rd


java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7

I am getting this exception
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7 and java.lang.NoClassDefFoundError: Could not initialize class org.co...


ModelMapper return Null in DTO fields while mapping from Entity to DTO

ModelMapper returns null in my DTO fields while mapping from Entity Object to Dto. Anyone please explain why I am getting Null response.
TestEntity
@Data
@Entity
@Table(name="TestEntity")
public ...


JWT[ RSA ], api owner shared private key

SO I have to write a Rest client for an integration we are working on with one of our client.
They gave us a private key and told us to create a JWT of the json payload.
Key:
"-----BEGIN RSA PRIV...


Print a prime triangle in JAVA

I am trying to print a triangle of 0s and 1s. You get a number N. If N was 5 the triangle should look like:
1
11
111
11101
I get wrong output with 27 for example
1
11
111
11101
11101010
11101010...


Micronaut - different validation for different operations

I have an JavaDTO like:
public class myDTO {
private String name;
private Integer age;
}
I want to do different validation in Micronaut by an CREATE operation and by an UPDATE operation. In


HAPI - How to stop SimpleServer correctly and prevent further connections

I am building an application with several server and client HL7 connections managed by a CommunicationProcess class. Part of the application's functionality is to restart that process when new


Next