Category "java"

Remove trailing substring from String in Java

I am looking to remove parts of a string if it ends in a certain string. An example would be to take this string: "[email protected]" And remove the @2x.p

How to pretty print a complex Java object (e.g. with fields that are collections of objects)? [closed]

I'm looking for a library function (ideally from a commonly used framework e.g. Spring, Guava, Apache Commons etc.) that will nicely print the

How do I resolve Could not find artifact javax.xml.bind:jaxb-api:pom:2.3.0-b161121.1438 in central (https://repo1.maven.org/maven2)?

I'm migrating an app to use ehcache 3.10.0 but getting a build error: Could not find artifact javax.xml.bind:jaxb-api:pom:2.3.0-b161121.1438 in central (https:/

Mock redis template

I am facing a issue in mock redis template. Can any one help me to write unit test for below class. @Repository public class CasheRepo { @Autowired pr

Remote debugging configuration: Java on Netbeans 12

I can successfully deploy and develop java projects remotely from a Windows machine on a RaspberryPi (Raspian). My IDE is Netbeans 12.6 which comes with the opt

IntelliJ (2018.3) with Thymeleaf - NO auto completion on paths to static content?

Code completion for paths and filenames do NOT seem to work in IntelliJ with Thymeleaf: th:src="@{...}" attributes - e.g. files in the resources/static/ folder.

How to prevent Bluetooth Disconnected when moving Fragment

I make a POS in android. I want to make a printing in my apps. To do printing I'm using bluetooth printer. Then, I had success make the bluetooth connection and

`java` command is not found from this Python process. Please ensure Java is installed and PATH is set for `java`

I don't know how to fix this error when I'm trying to run the following code: df = wrapper.read_pdf(r'C:\End_to_End\1902\PN\Scenario1_AllCorrectMin\EPR.pdf

Using reflection to identify if the error thrown matches expected error

I need to write a simple code tester program, but I got stuck comparing the given error class with the test expected class. I am supposed to use reflection in t

Compiling multi module maven projects without installing to local repository

I have a compiling (and packaging) problem in my multi-module maven project. Problem occurs when compiling one of two projects which are siblings and included i

`java` command is not found from this Python process. Please ensure Java is installed and PATH is set for `java`

I don't know how to fix this error when I'm trying to run the following code: df = wrapper.read_pdf(r'C:\End_to_End\1902\PN\Scenario1_AllCorrectMin\EPR.pdf

Hadoop configuration object not pointing to hdfs file system

I am trying to create small Spark program in Java. I am creating a Hadoop configuration object as show below: Configuration conf = new Configuration(false); con

args4J doesn't work with gradle

I'm totally new to gradle so it may be a obvious problem: I'm using eclipse with gradle and I actually have no problem adding dependencies for junit or stuff,

Why the insertion sort is slower than selection sort?

The code for selection sort in Java: public class Selection { public static void sort(Comparable[] a) { int n = a.length; for (int i = 0; i

@PreAuthorize stops propagating exceptions thrown during evaluation of security checks

I have a controller with several endpoints. Every endpoint is mapped to a service which could return 200 or throw an exception, that is then handled and will re

How to set Google Recaptcha Enterprise verification Using Api Key In Java Language?

I am not being able to connect to POST url: https://recaptchaenterprise.googleapis.com/v1/projects/PROJECT_ID/assessments?key=API_KEY JSON BODY: { "event": { "t

CompletableFuture | thenApply vs thenCompose

I can't get my head around the difference between thenApply and thenCompose. So, could someone provide a valid use case? From the Java docs: thenApply(Function&

How to find the last word in a string

I'm trying to create a method that returns the last word in a string but I am having some trouble writing it. I am trying to do it by finding the last blank s

No signature of method: .android() is applicable for argument types. Exception in build.gradle (app)

Exception is: org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app' Caused by: groovy.lang.MissingMethodException: No signature of

java.lang.ClassNotFoundException: org.apache.poi.ss.usermodel.Workbook

I'm trying to access an excel file the Apache Workbook module. The code runs perfectly sometimes, but mostly I get an error saying: exception javax.se